gpt4 book ai didi

Android screenOrientation API 18 - "nosensor"与 "locked"和 "unspecified"与 "user"与 "fullUser"

转载 作者:搜寻专家 更新时间:2023-11-01 08:57:29 25 4
gpt4 key购买 nike

Jelly Bean 4.3 (API 18) 添加了几个新的 screenOrientation 值。

http://developer.android.com/reference/android/R.attr.html#screenOrientation

http://developer.android.com/reference/android/content/pm/ActivityInfo.html#SCREEN_ORIENTATION_BEHIND

我想首先:“方向”和“旋转”之间有区别吗?或者文档只是使用了不一致的措辞?

然后:

unspecified

No preference specified: let the system decide the best orientation. This will either be the orientation selected by the activity below, or the user's preferred orientation if this activity is the bottom of a task. If the user explicitly turned off sensor based orientation through settings sensor based device rotation will be ignored. If not by default sensor based orientation will be taken into account and the orientation will changed based on how the user rotates the device. Corresponds to SCREEN_ORIENTATION_UNSPECIFIED.

user

Use the user's current preferred orientation of the handset. Corresponds to SCREEN_ORIENTATION_USER.

fullUser (New)

Respect the user's sensor-based rotation preference, but if sensor-based rotation is enabled then allow the screen to rotate in all 4 possible directions regardless of what the device will normally do (for example some devices won't normally use 180 degree rotation). Corresponds to SCREEN_ORIENTATION_FULL_USER.

有什么区别?目前在实践中,我相信 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) 是告诉 Activity 根据传感器旋转的方式,如果旋转在系统范围内启用。那么 fulluser 有何不同呢?

同样,

nosensor

Always ignore orientation determined by orientation sensor: the display will not rotate when the user moves the device. Corresponds to SCREEN_ORIENTATION_NOSENSOR.

locked (New)

Screen is locked to its current rotation, whatever that is. Corresponds to SCREEN_ORIENTATION_LOCKED.

有什么不同吗?

最佳答案

Is there a difference between "orientation" and "rotation"? Or is thedocumentation just using inconsistent wording?

即使您将 OrientationRotation 视为同义词(包括我在内的大多数人都这么认为),区别在于它们各自的定义。 Orientation 为您提供两种选择,Rotation 为您提供四种选择。多出来的两个选择有什么用?这将取决于您。

假设您想出了一款便捷应用,其中包括闹钟、计算器、天气预报器和货币转换器。您可以为其中的每一个分配不同的旋转角度,并允许用户通过旋转设备在四个 View 之间导航。

另一个(虚构的)示例可以是主屏幕,它根据旋转角度显示不同的小部件组。

我尝试了一些 screenOrientation 选项,这是我发现的:

fullUser: Stuck to the default rotation of 0 degrees.

user: Allowed rotation values 0, 90 and 270.

fullSensor: Allowed all 4 rotation values.

unspecified: Same behavior as user setting

locked and nosensor: Stuck to 0 degree rotation

正如您从测试中看到的那样,关于每个 screenOrientation 值的作用并没有太多说明。不确定为什么我无法重现资源页面上定义的效果。

关于Android screenOrientation API 18 - "nosensor"与 "locked"和 "unspecified"与 "user"与 "fullUser",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17900794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com