android layout - Titanium handling different resoutions -


simple question, best way make sure app works on different screen resolutions without looking crap? can't use static values, want adjust according resolution. right using relative measurements (percentage of screen) wonder if that's best way handle it!?

another/additional option have been successful small set of functions use screen density value compute display sizes... of course approximation, there 4 densities, have found helpful.

//============================================================================= // inch // // compute approximate number of pixels specified physical on-screen // size based on density reported os //============================================================================= function inch(size) {     // default 160 dpi if unavailable     var height = size * 160.0;       try     {          // compute header height based on screen density ... target .25" height         height = size * ti.platform.displaycaps.dpi;      }     catch(e) { warn("error accessing display caps screen density calculation: " + e); }      return height; } 

so if want 3/4 inch high on screen....

ti.ui.creatething({ height: inch(.75)}); 

...or if want scale things point size, 1 make constants...

const g_12pt = inch(12/72); //0.166667 const g_10pt = inch(10/72); //0.138889 const g_8pt = inch(8/72);   //0.111111 const g_6pt = inch(6/72);   //0.083333 ... ...font:{fontsize: g_10pt, fontweight:"bold"},... 

we created couple of functions screen height , width, if wanted better layout on tablet or tiny better understand dealing with.

//============================================================================= // screenwidth - return screen width in inches //============================================================================= function screenwidth() {     return titanium.platform.displaycaps.platformwidth / titanium.platform.displaycaps.dpi; }  //============================================================================= // screenheight - return screen height in inches //============================================================================= function screenheight() {     return titanium.platform.displaycaps.platformheight / titanium.platform.displaycaps.dpi; } 

you can go on , on there... helped nail down how laid out our screens on different densities , platforms. inch function has exception handling because use in app, , ti.platform still undefined. time laying out our reports ti.platform available , screen functions not have exception handling. if need query earlier may need exception handling in well.

hope helps!


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -