Skip to content

Instantly share code, notes, and snippets.

@exclusiveTanim
Created June 17, 2019 18:31
Show Gist options
  • Save exclusiveTanim/b12700012ee22dce01d1eb983ece3d70 to your computer and use it in GitHub Desktop.
Save exclusiveTanim/b12700012ee22dce01d1eb983ece3d70 to your computer and use it in GitHub Desktop.
CSN: 01058435
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
var verticalView = Ti.UI.createView({layout: 'vertical', width: "100%", height: "100%"});
verticalView.add(Ti.UI.createLabel({text: 'Label 1', top: 30, width: Ti.UI.SIZE, height: Ti.UI.SIZE}));
var htmla = "<div style='font-family: Helvetica Neue; font-size:16px'><ul><li>Item 1</li><li>Item 2</li></ul></div>";
var html = "<!DOCTYPE html>";
html += "<html><head><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'><style type='text/css'>html {-webkit-text-size-adjust: none;}</style><script type='text/javascript'>document.ontouchmove = function(event){event.preventDefault();}</script></head><body style='overflow: hidden'>";
html += htmla;
html += "</body></html>";
var webview = Ti.UI.createWebView({left: '14dp', right: '14dp', top: '7dp', height: Ti.UI.SIZE, html: html, backgroundColor: "yellow"});
verticalView.add(webview);
verticalView.add(Ti.UI.createLabel({text: 'Label 2', top: 30, width: Ti.UI.SIZE, height: Ti.UI.SIZE}));
win.add(verticalView);
win.open();
webview.addEventListener('load', function(e) {
var result = webview.evalJSSync('document.body.scrollHeight');
Ti.API.info('webview height: ' + result);
webview.height = result;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment