我正在为 Android 平板电脑编写应用程序。我希望 ScreenOrientation 始终处于“横向”状态,但应用程序应该能够旋转 180°。如果您将平板电脑倒置,则 View 应正确显示并旋转 180°。
有没有简单的方法来做到这一点?目前,我只在我为 Activity 编写 android:screenOrientation="landscape"
的 list 中强制应用程序处于横向模式。但轮换不会那样工作。
最佳答案
请改用 android:screenOrientation="sensorLandscape"
。
Landscape orientation, but can be either normal or reverse landscape based on the device sensor. Added in API level 9.
注意,如果你在activity标签中使用android:configChanges="orientation"
来避免屏幕旋转,那么屏幕根本不会旋转。如果您希望它仅在横向旋转,请使用上述选项并删除方向标志。在使用此选项之前检查您想要的行为。
关于仅限 Android 旋转横向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8615335/