Hi guys! How do I fit any image on any resolution device? I tried to use width 100% in imageview, but was larger than the screen. my code:
function Image(){ WindoOptions = { fullscreen : true, modal : false, navBarHidden : true }; var win = Ti.UI.createWindow(WindoOptions); var images = []; var image_url = null;tra var image_view = null; var container_view = null; var activityIndicator = Ti.UI.createActivityIndicator({ message : "Carregando..." }); win.add(activityIndicator); activityIndicator.show(); var getData = function (){ var xhr = Ti.Network.createHTTPClient(); xhr.onload = function(){ var tn = JSON.parse(this.responseText); for(i=0; i < tn.length; i++){ container_view = Ti.UI.createView({backgroundColor: "red",}); image_url= tn[i].foto; elWidth = tn[i].size[0] > Ti.Platform.displayCaps.platformWidth ? Ti.Platform.displayCaps.platformWidth : tn[i].size[0]; image_view = Ti.UI.createImageView({ image:image_url, backgroundColor: "blue", width: tn[i].size[0], height : "auto", }); container_view.add(image_view); images.push(container_view); } var imageGallery = Titanium.UI.createScrollableView({ views:images, height : Titanium.Platform.displayCaps.platformHeight - 40, backgroundColor: "white", width : Titanium.Platform.displayCaps.platformWidth, contentWidth: Ti.UI.FILL, maxZoomScale : 2, minZoomScale : 0, }); win.add(imageGallery); activityIndicator.hide(); return win.open({ activityEnterAnimation: Ti.Android.R.anim.slide_in_left, activityExitAnimation: Ti.Android.R.anim.slide_out_right }); } xhr.open('GET',"http://localhost/arquivo.json"); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.send(); } return getData(); } module.exports = Image;