android:screenOrientation= "portrait"在运行棉花糖的 Nexus 5x 上被忽略



我收到报告说,我的肖像应用程序可以在运行棉花糖的Nexus 5X上旋转到横向模式。我没有一个可以测试的,但为什么会发生这种情况?这是我在清单中的活动:

    <activity
            android:name=".app.MainActivity_"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.Activity"
            android:launchMode="singleTask"
            >
    </activity>

尝试将tragetSDKVersionMarshmallow更改为Lollipop

它对我有效。

您必须将其用于"活动"!

<activity
   android:screenOrientation="portrait"
   android:configChanges="orientation|keyboardHidden">
</activity>

对于整个应用程序,您必须使用此代码,这将强制方向不是横向

<application 
  android:debuggable="true"
  android:icon="@drawable/icon" 
  android:label="@string/app_name"
  android:configChanges="orientation"       
  android:screenOrientation="portrait">

最新更新