I'm having trouble making my Android app fit to different screen sizes. Although you've heard this question many times before, I'm yet to find a definitive answer by trawling through the Q&A or documentation.
I was under the impression that using dp values would mean "device independent pixels" and should be at least semi-fluid for 2 portrait screens.
I've been testing on a Samsung Galaxy S and a Samsung Galaxy Ace - Here's what I've tried so far for ImageView.width
- width:'85%' [crashes - is this a BUG ?]
- MyImgWidth = Math.floor(Ti.UI.currentWindow.width * 0.8); [crashes - is this a BUG ?]
- width: '175dp' [doesn't crash but inconsistent on the two screen resolutions]
God only knows what I'm going to do to get the app to fit on my GF's HTC Cha-Cha! :-D
Nevermind, thanks to this post I've finally figured it out like this:
MyImgWidth = Math.floor(Titanium.Platform.displayCaps.platformWidth * 0.9); MyImgHeight = Math.floor(MyImgWidth * 0.21); //this figure pre-calculated by me - Actual Image Width / Actual Image Height - as it is a horizontal button.But the poster reckons you can do Math.Floor(win.width * 0.8) - which I've found to crash. Stick with Titanium.Platform.displayCaps.platformWidth
Think you can help? Login to answer this question!