2012年10月10日 星期三

[AndroidDev] Screen Compatibility Mode

Notice:
如果你所開發的 app,是小於 Android 3.0 且已經能在 tablet 上正常顯示,應該關閉此功能以維持 the best user experience。

Definition:
  • 為了幫助不能在大螢幕上正常顯示 layout 的 app 的模式。
  • 但!! Screen compatibility mode 不是作為解決顯示在 larger screen 的根本方法,因為他是放大 layout 因此使得畫面變模糊。


有以下兩種版本:

Version 1 (Android 1.6 - 3.1)
  • 系統以 normal size 來畫 layout,剩餘沒填滿的地方,則都填入黑色。
  • 僅適用於 screen size 320dp x 480dp。
  • To disable this version of screen compatibility mode, you simply need to set 
    • android:minSdkVersion or android:targetSdkVersion to "4" or higher, or
    • android:resizeable = "true".
Version 2 (Android 3.2 and greater)
  • 系統以 normal size 來畫 layout,再放大 layout 填滿 screen,所以可能會顯得模糊。
  • 如果 app 沒有宣告 <supports-screens android:largeScreens="true" />,那在 system bar 會出現選項(an icon with outward-pointing arrows)讓 user 選擇是否開啟此功能;但若 app 有宣告,user 則不能選擇。

Disabling Screen Compatibility Mode

讓 user 自行選擇是否使用(>= Android 3.2):
  • set both android:minSdkVersion and android:targetSdkVersion to "10" or lower and does not explicitly declare support for large screens using the <supports-screens> element.
  • set either android:minSdkVersion or android:tagetSdkVersion to "11" or higher and explicitly declares that it does not support large screens, using the <supports-screens> element.

Easiest:
表示支援所有大小的 screen,系統會 resize layout 每個 screen。


Easy but has other effects:
In your manifest's <uses-sdk> element, set android:targetSdkVersion to "11" or higher:

表示你的 app 支援 Android 3.0 與能正常執行於 larger screen size。

Caution:
When running on Android 3.0 and greater, this also has the effect of enabling the Holographic theme for you UI, adding the Action Bar to your activities, and removing the Options Menu button in the system bar.
If screen compatibility mode is still enabled after you change this, check your manifest's and be sure that there are no attributes set "false".


Enabling Screen Compatibility Mode

  • 如果是開發 Android 3.2 (API level 13) or higher 的 app 可以用 <supports-screens> 決定是否使用次功能。
  • 設定 android:minSdkVersion or android:targetSdkVersion to "11" or higher,user 則不能使用。(?)
If either of these are true and your application does not resize properly for larger screens, you can choose to enable screen compatibility mode in one of the following ways:

表示你 app 支援的 the maximum "smallest screen width" 是 320 dp,也就是說當 device screen 的 smallest screen width 大於 320 dp,user 就能使用 screen compatibility mode。

強制開啟此功能
If your application is functionally broken when resized for large screens and you want to force users into screen compatibility mode (rather than simply providing the option), you can use the android:largestWidthLimitDp attribute:


<supports-screens> 設為 true,表示你的 app 支援該大小的 screen,不使用此功能。


* Reference
- Screen Compatibility Mode
- Screen Compatibility Mode

沒有留言:

張貼留言