问题描述
我希望我的活动只能在两种纵向模式下使用 - 纵向和反向纵向.我怎样才能做到这一点?当我设置 android:screenOrientation="portrait"
时,它会强制活动仅在正常的纵向模式下 - 反之亦然.
I want my activity to be available only in both portrait modes - portrait and reversePortrait. How can I achieve this? When I set android:screenOrientation="portrait"
it will force activity to be only in normal portrait - vice versa with reversePortrait.
请不要告诉我这是强制/锁定方向的糟糕方法.我知道它,但客户仍然要求它.感谢您的理解和任何想法.
Please, don't tell me it's a bad approach to force/lock orientation. I know about it, but still client is requesting it. Thanks for understanding and for any ideas.
更新:API 级别 11 及更高
UPDATE: API Level 11 and higher
推荐答案
如果您使用的是 API 级别 9+,请使用 android:screenOrientation="sensorPortrait"
.
If you are on API level 9+, use android:screenOrientation="sensorPortrait"
.
纵向,但可以是正常或反向纵向基于设备传感器.在 API 级别 9 中添加.
这篇关于仅限纵向或反向纵向活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!