我想让我的应用保持纵向模式。只需一个基本的空活动,我就将前两行添加到清单中的应用程序信息中:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lxg.golf">
<application
android:resizeableActivity="false"
android:screenOrientation="portrait"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Golf">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
但它仍然在我的设备(Galaxy S8,Android 版本 9)上旋转为横向。我怎样才能让它保持纵向?
答案 0 :(得分:0)
您应该为每个活动添加 screenOrientation
属性:
<activity android:name=".MainActivity"
android:screenOrientation ="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>