Android 中仅允许 2 个屏幕方向?
Allow only 2 screen orientations in Android?
要仅在 1 个屏幕方向上将应用锁定为 运行,我们可以在 AndroidManifest.xml
中执行此操作:
<activity
android:name="..."
android:screenOrientation="portrait"/>
问题是,我刚刚发现我需要让应用程序也可以旋转到 reversePortrait
,我首先尝试的是:
<activity
android:name="..."
android:screenOrientation="portrait|reversePortrait"/>
但是android:screenOrientation
好像只允许1个值。那我们还能怎样做到这一点?
你想要的是:
<activity
android:name="..."
android:screenOrientation="sensorPortrait"/>
参见 here。
要仅在 1 个屏幕方向上将应用锁定为 运行,我们可以在 AndroidManifest.xml
中执行此操作:
<activity
android:name="..."
android:screenOrientation="portrait"/>
问题是,我刚刚发现我需要让应用程序也可以旋转到 reversePortrait
,我首先尝试的是:
<activity
android:name="..."
android:screenOrientation="portrait|reversePortrait"/>
但是android:screenOrientation
好像只允许1个值。那我们还能怎样做到这一点?
你想要的是:
<activity
android:name="..."
android:screenOrientation="sensorPortrait"/>
参见 here。