分别在我的build.gradle(Module:app)文件中将compileSdkVersion 26
&targetSdkVersion 26
升级为compileSdkVersion 27
&targetSdkVersion 27
时,所有其他Android版本,但在Android 8.0(API级别26)模拟器中遇到以下错误:
由:java.lang.IllegalStateException引起:仅全屏不透明活动可以要求方向
删除android:screenOrientation="portrait"
对我有用,但是现在我的屏幕旋转了(我不想这么做)。
再次切换回compileSdkVersion 26
可以双向操作,即我没有任何错误,并且活动屏幕也仅限于纵向。
但是我的问题是,仅在Android 8.0(API级别26)中将屏幕方向限制为纵向模式,而将Android Android 8.1(API级别27)作为目标。
任何帮助将不胜感激。谢谢!!
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.thcb.app">
<application
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/AppTheme">
<activity android:name=".MainActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>