我希望我的Andr​​oid应用程序将仅在纵向模式下运行?我的、纵向、应用程序、模式下

2023-09-05 05:28:28 作者:﹏譆揂嶼妳ゞ

我希望我的Andr​​oid应用程序将仅在纵向模式下运行? 我该怎么办呢?

I want my android application to be only run in portrait mode? How can I do that?

推荐答案

在清单中,设置此为您的所有活动:

In the manifest, set this for all your activities:

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

让我来解释一下:

使用机器人:configChanges =定向你告诉Android的,你会负责的取向变化 机器人:screenOrientation =肖像设置默认的方向模式 With android:configChanges="orientation" you tell Android that you will be responsible of the changes of orientation. android:screenOrientation="portrait" you set the default orientation mode.