Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

How to target many screen resolutions

$
0
0

I have a tss that looks like this:

".row[if=Alloy.Globals.is3to2]": {
    height: 153,
}
".row[if=Alloy.Globals.is5to3]": {
    height: 138,
}
".row[if=Alloy.Globals.is4to3]": {
    height: 172,
}
".row[if=Alloy.Globals.is16to10]": {
    height: 144,
}
".row[if=Alloy.Globals.is16to9]": {
    height: 129,
}
In my alloy.js file I do this:
const RATIO = Ti.Platform.displayCaps.platformWidth / Ti.Platform.displayCaps.platformHeight;
 
Alloy.Globals.is3to2 = RATIO.toFixed(4) == 0.6667;
Alloy.Globals.is5to3 = RATIO.toFixed(1) == 0.6;
Alloy.Globals.is4to3 = RATIO == 0.75;
Alloy.Globals.is16to10 = RATIO == 0.625;
Alloy.Globals.is16to9 = RATIO == 0.5625;
My goal is that an element with row class, on every device should occupy the same amount of space. When I run emulator of Google Nexus 7 (800x1280) I get RATIO of 0.66211... which is wrong because 800 / 1280 = 0.625, hovewer when I log platformWidth and platformHeight I get 533 (should be 800) and 805 (should be 1280), and 533 / 805 = 0.66211... On different emulators (480x800, 720x1280, it's the same) How to get real platformWidth and height?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>