在Android中仅允许2个屏幕方向?

时间:2023-01-18 09:04:06

To lock the app to run in only 1 screen orientation, we could do this in AndroidManifest.xml:

要锁定应用程序以仅在1个屏幕方向上运行,我们可以在AndroidManifest.xml中执行此操作:

<activity
        android:name="..."
        android:screenOrientation="portrait"/>

The issue is, I just found out that I need to make the app also rotatable to reversePortrait, first thing I tried is:

问题是,我发现我需要让应用程序也可以转向reversePortrait,我尝试的第一件事是:

<activity
        android:name="..."
        android:screenOrientation="portrait|reversePortrait"/>

But it seems that android:screenOrientation only allows 1 value. How else then could we achieve this?

但似乎android:screenOrientation只允许1个值。那我们怎么能做到这一点呢?

1 个解决方案

#1


4  

What you want is:

你想要的是:

<activity
        android:name="..."
        android:screenOrientation="sensorPortrait"/>

see here.

#1


4  

What you want is:

你想要的是:

<activity
        android:name="..."
        android:screenOrientation="sensorPortrait"/>

see here.