Android:禁用 90° 旋转,但启用 180° 旋转
我想创建一个仅以横向显示的 Android 应用程序(适用于平板电脑),例如应用程序应忽略 90° 旋转,但支持 180° 旋转。
在清单中添加 android:screenOrientation="landscape" 会导致应用程序忽略所有旋转(甚至 180° 旋转),即设备旋转 180° 会显示应用程序上下颠倒。
如果没有 android:screenOrientation 属性,我的应用程序将在所有四个位置“正确”显示。将设备旋转 180° 会垂直翻转 UI。水平地。
旋转设备时,会创建以下日志消息(也许这有帮助?):
[...]: INFO/WindowManager(1290): Setting rotation to 1, animFlags=0
Rotation is a value between 0 and 3 representing the current orientation.
总结:是否可以使应用程序支持两种横向方向?
I would like to create an Android app (for a tablet) that should be only displayed in landscape orientation, e.g. the app should ignore rotations by 90°, but support rotations by 180°.
Adding android:screenOrientation="landscape" in the manifest causes the app to ignore all rotations, (even the 180° rotations), i.e. rotating the device by 180° shows the application upside down.
Without the android:screenOrientation attribute my app is displayed "correctly" in all four positions. Rotation the device by 180° flips the UI vertically resp. horizontally.
When rotation the device the following log messages are created (maybe this helps?):
[...]: INFO/WindowManager(1290): Setting rotation to 1, animFlags=0
Rotation is a value between 0 and 3 representing the current orientation.
Summarized: Is it possible to enable an app to support both landscape orientations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
新的 sensorLandscape 屏幕方向显然适用于这个目的。
例如,您可以这样做:
不幸的是,这仅适用于 Android 2.3。我目前正在寻找一种方法来在 Froyo 上实现这一目标。
The new sensorLandscape screen orientation is apparently meant for this purpose.
Eg, you could do:
Unfortunately, this is only available as of Android 2.3. I'm currently looking for a way to achieve this on Froyo.