Screens Support APIs for Android 3.2
Screens Support APIsの要点まとめ。(英文は説明が"くどい"ので箇条書き風に)
ほとんどDeveloperブログに記載されていたCompatibilityモード関連です。
- 既存のScreen Support API上に構築されている
- プラットフォームは新たな3つの特性(smallestWidth, width, height)を使用して、使用可能なスペースを表現
- smallestWidthは画面サイズの短辺
- 新しいResource修飾子の追加
タグに新しい属性の追加
新しいResource修飾子
新しいResource修飾子が追加されています。
- swNNNdp:リソースが使用されるに最小smallestWidthを指定(例: sw320dp, sw720dp, sw720dp)
- wNNNdp と hNNNdp:リソースが使用されるに最小height,widthを指定(例: w320dp, w720dp, h1024dp)
Resource修飾子の使用例
res/layout/main_activity.xml # For phones
res/layout-sw600dp/main_activity.xml # For 7” tablets
res/layout-sw720dp/main_activity.xml # For 10” tablets
res/layout-w600dp/main_activity.xml # Multi-pane when enough width
res/layout-sw600dp-w720dp/main_activity.xml # For large width
3.1以前のandroid端末のために、従来のResource修飾子と混在してもOK
res/layout/main_activity.xml # For phones
res/layout-xlarge/main_activity.xml # For pre-3.2 tablets
res/layout-sw600dp/main_activity.xml # For 3.2 and up tablets
AndroidManifest.xmlに記載できる新しい属性
android:compatibleWidthLimitDp="numDp"
アプリケーションのCompatibilityモードを必要とせずに実行できる最大smallestWidthを指定できます。画面が指定した値よりも大きい場合、システムは通常のモードでアプリケーションが表示されますが、SystemBarにてCompatibilityモードを切り替えることができる。
android:largestWidthLimitDp="numDp"
アプリケーションが実行できる最大smallestWidthを指定できます。画面が指定した値よりも大きい場合、強制的にCompatibilityモードで実行します。
画面のCompatibilityモード
Android3.2は新しいCompatibilityモードを用意し、SystemBar上にて"Zoom"モードをOn/Offに切り替えるユーザーオプションとして使用できます。
詳細はDeveloperブログに紹介されています。
上記で紹介した属性をAndroidManifest.xmlに記載することで"Zoom"モードを無効にできます。
720pTV用のDensityを追加
720pのテレビ上で稼働するアプリケーションのニーズを満たすために、"tvdpi"を追加。
DisplayMetricsのクラスに
public static final int DENSITY_TV
が追加されています。
Resource修飾子の使用例
res/drawable-tvdpi/my_icon.png # Bitmap for tv density