Ti.Platform.displayCaps.platformWidthの使い方ではまる by titanium android
titanium androidでviewを横に7つ並べようと
width値を計算して設定
Math.floor(Ti.Platform.displayCaps.platformWidth/7)
tishadowではうまく動いたのに実機に入れたら横幅あわない・・・
androidの場合は、widthはdp指定じゃないとだめ?
参考リンクからpx、dp変換関数を持ってきて
function PixelsToDPUnits(ThePixels) { if ( Titanium.Platform.displayCaps.dpi > 160 ) return (ThePixels / (Titanium.Platform.displayCaps.dpi / 160)); else return ThePixels; }
いけたー
PixelsToDPUnits(Math.floor(Ti.Platform.displayCaps.platformWidth/7))+"dp"