android:screenOrientation的說明

在Android的官方文檔當中,對android:screenOrientation的說明如下:

android:screenOrientation The orientation of the activity's display on the device.

The value can be any one of the following strings:

"unspecified" The default value. The system chooses the orientation. The policy it uses, and therefore the choices made in specific contexts, may differ from device to device.
"user" The user's current preferred orientation.
"behind" The same orientation as the activity that's immediately beneath it in the activity stack.
"landscape" Landscape orientation (the display is wider than it is tall).
"portrait" Portrait orientation (the display is taller than it is wide).
"reverseLandscape" Landscape orientation in the opposite direction from normal landscape.Added in API level 9.
"reversePortrait" Portrait orientation in the opposite direction from normal portrait.Added in API level 9.
"sensorLandscape" Landscape orientation, but can be either normal or reverse landscape based on the device sensor. Added in API level 9.
"sensorPortrait" Portrait orientation, but can be either normal or reverse portrait based on the device sensor. Added in API level 9.
"sensor" The orientation is determined by the device orientation sensor. The orientation of the display depends on how the user is holding the device; it changes when the user rotates the device. Some devices, though, will not rotate to all four possible orientations, by default. To allow all four orientations, use "fullSensor".
"fullSensor" The orientation is determined by the device orientation sensor for any of the 4 orientations. This is similar to "sensor" except this allows any of the 4 possible screen orientations, regardless of what the device will normally do (for example, some devices won't normally use reverse portrait or reverse landscape, but this enables those). Added in API level 9.
"nosensor" The orientation is determined without reference to a physical orientation sensor. The sensor is ignored, so the display will not rotate based on how the user moves the device. Except for this distinction, the system chooses the orientation using the same policy as for the "unspecified" setting.

Note: When you declare one of the landscape or portrait values, it is considered a hard requirement for the orientation in which the activity runs. As such, the value you declare enables filtering by services such as Google Play so your application is available only to devices that support the orientation required by your activities. For example, if you declare either "landscape","reverseLandscape", or "sensorLandscape", then your application will be available only to devices that support landscape orientation. However, you should also explicitly declare that your application requires either portrait or landscape orientation with the <uses-feature> element. For example, <uses-feature android:name="android.hardware.screen.portrait"/>. This is purely a filtering behavior provided by Google Play (and other services that support it) and the platform itself does not control whether your app can be installed when a device supports only certain orientations.

譯文爲:

android:screenOrientation

Activity在屏幕當中顯示的方向。屬性值可以是下表中列出的一個值:

"unspecified" 默認值,由系統來選擇方向。它的使用策略,以及由於選擇時特定的上下文環境,可能會因爲設備的差異而不同。
"user" 使用用戶當前首選的方向。
"behind" 使用Activity堆棧中與該Activity之下的那個Activity的相同的方向。
"landscape" 橫向顯示(寬度比高度要大)
"portrait" 縱向顯示(高度比寬度要大)
"reverseLandscape" 與正常的橫向方向相反顯示,在API Level 9中被引入。
"reversePortrait" 與正常的縱向方向相反顯示,在API Level 9中被引入。
"sensorLandscape" 橫向顯示,但是基於設備傳感器,既可以是按正常方向顯示,也可以反向顯示,在API Level 9中被引入。
"sensorPortrait" 縱向顯示,但是基於設備傳感器,既可以是按正常方向顯示,也可以反向顯示,在API Level 9中被引入。
"sensor" 顯示的方向是由設備的方向傳感器來決定的。顯示方向依賴與用戶怎樣持有設備;當用戶旋轉設備時,顯示的方向會改變。但是,默認情況下,有些設備不會在所有的四個方向上都旋轉,因此要允許在所有的四個方向上都能旋轉,就要使用fullSensor屬性值。
"fullSensor" 顯示的方向(4個方向)是由設備的方向傳感器來決定的,除了它允許屏幕有4個顯示方向之外,其他與設置爲“sensor”時情況類似,不管什麼樣的設備,通常都會這麼做。例如,某些設備通常不使用縱向倒轉或橫向反轉,但是使用這個設置,還是會發生這樣的反轉。這個值在API Level 9中引入。
"nosensor" 屏幕的顯示方向不會參照物理方向傳感器。傳感器會被忽略,所以顯示不會因用戶移動設備而旋轉。除了這個差別之外,系統會使用與“unspecified”設置相同的策略來旋轉屏幕的方向。

注意:在給這個屬性設置的值是“landscape”或portrait的時候,要考慮硬件對Activity運行的方向要求。正因如此,這些聲明的值能夠被諸如Google Play這樣的服務所過濾,以便應用程序只能適用於那些支持Activity所要求的方向的設備。例如,如果聲明瞭“landscape”、“reverseLandscape”、或“sensorLandscape”,那麼應用程序就只能適用於那些支持橫向顯示的設備。但是,還應該使用<uses-feature>元素來明確的聲明應用程序所有的屏幕方向是縱向的還是橫行的。例如:<uses-feature android:name=”android.hardware.screen.portrait”/>。這個設置由Google Play提供的純粹的過濾行爲,並且在設備僅支持某個特定的方向時,平臺本身並不控制應用程序是否能夠被按照。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章