Android(安卓)8.0系统Bug Only fullscreen opaque activities can request orientation
16lz
2021-01-26
这是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(安卓)标题栏TitleBar布局
- Android(安卓)Gradle plugin与Gradle 版本对应问题
- Android(安卓)P系统设置之默认打开定位开关(默认使用位置服务)
- java.lang.UnsupportedClassVersionError: com/android/build/gr
- C99标准之宏定义_可变参数宏_#_##
- Android(安卓)最火框架XUtils之注解机制详解
- android用户界面-组件Widget-网格视图GridView
- Android应用开发UI(日期和时间)
- Android(安卓)自定义Dialog 控制