0
さまざまなプラットフォームに応じて画像の高さと幅を動的に変更したいと考えています。appceleratorのプラットフォーム固有の高さと幅
appceleratorのplatform.heightとplatform.widthのドキュメントを確認しました。しかし、私はそれがどのように行われたのか理解できないようです。
さまざまなプラットフォームに応じて画像の高さと幅を動的に変更したいと考えています。appceleratorのプラットフォーム固有の高さと幅
appceleratorのplatform.heightとplatform.widthのドキュメントを確認しました。しかし、私はそれがどのように行われたのか理解できないようです。
このクロスプラットフォームコードを使用して、Android/iOSデバイスの幅を& dpに設定できます。
alloy.js
var df = Ti.Platform.displayCaps.logicalDensityFactor;
var w = OS_IOS ? Ti.Platform.displayCaps.platformWidth : Ti.Platform.displayCaps.platformWidth/df;
var h = OS_IOS ? Ti.Platform.displayCaps.platformHeight : Ti.Platform.displayCaps.platformHeight/df;
Alloy.Globals.deviceWidth = Math.min(w, h);
Alloy.Globals.deviceHeight = Math.max(w, h);
今、あなたはこのようにしたい任意のファイルでこれらのグローバル変数を使用することができます:あなたが達成するために正確に何をしようとしている
"#someLabel": {
width : Alloy.Globals.deviceWidth,
height : 100
}
? –