titanium mobile : Titanium.Platform.DisplayCaps
width
アンドロイドはpixels, ios は dipが返されるようです。
(dip : Device independent pixel (also: density-independent pixel)
Absolute width of the display in relation to UI orientation. Measured in platform-specific units; pixels on Android and density-independent pixels (dip) on iOS.
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Platform.DisplayCaps
iPhone 320 x480
iPad 768 x 1024 : 720 に併せて。
なので。
android は
small 320 – iphone共通
medium 480,540
large 720,800 – ipad共通
な感じで
3種類のスタイルを用意したら良い感じになりそうです。
横幅は基本 % 指定で共通。
縦は、それぞれ用に固定指定。
スタイルは全部のファイルから利用するので、何度も呼ぶ必要が無いようにTi.Appに付けておきます。
app.jsで一度だけ設定します。
switch( Ti.Platform.osname ){
case ‘iphone':
Ti.App.style = require(‘/ui/style/base_320′);
break;
case ‘ipad':
Ti.App.style = require(‘/ui/style/base_720′);
break;
case ‘android':
if( Ti.Platform.displayCaps.platformWidth >= 720 ) {
Ti.App.style = require(‘/ui/style/base_720′);
}else if( Ti.Platform.displayCaps.platformWidth >= 480 ) {
Ti.App.style = require(‘/ui/style/base_480′);
}else{
Ti.App.style = require(‘/ui/style/base_320′);
}
break;
}
case ‘iphone':
Ti.App.style = require(‘/ui/style/base_320′);
break;
case ‘ipad':
Ti.App.style = require(‘/ui/style/base_720′);
break;
case ‘android':
if( Ti.Platform.displayCaps.platformWidth >= 720 ) {
Ti.App.style = require(‘/ui/style/base_720′);
}else if( Ti.Platform.displayCaps.platformWidth >= 480 ) {
Ti.App.style = require(‘/ui/style/base_480′);
}else{
Ti.App.style = require(‘/ui/style/base_320′);
}
break;
}