Android 8.0系统Bug Only fullscreen opaque activities can request orientation

这是Android8.0系统的问题,其他版本没有问题8.1及之后都没有

先看下AOSP 源码

if (ActivityInfo.isFixedOrientation(requestedOrientation) // 是否锁定了屏幕方向
    && !fullscreen // 不是全屏
    && appInfo.targetSdkVersion >= O) { // targetsdkversion版本是Android8及以上
    throw new IllegalStateException("Only fullscreen activities can request orientation");
}
public static boolean isTranslucentOrFloating(TypedArray attributes) { 
    final boolean isTranslucent = attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent, false); 
    final boolean isSwipeToDismiss = !attributes.hasValue( com.android.internal.R.styleable.Window_windowIsTranslucent) 
                                     && attributes.getBoolean( com.android.internal.R.styleable.Window_windowSwipeToDismiss, false); 
    final boolean isFloating = attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsFloating, false);  
    return isFloating || isTranslucent || isSwipeToDismiss;    
}

就是三个参数值 windowIsTranslucent,windowSwipeToDismiss,windowIsFloating在设置全屏style的时候, 不要设置这几个参数为true

 

参考:
https://www.jianshu.com/p/e6b5e7261c25

你可能感兴趣的:(android)