Dilaog实现沉浸式全屏:
(112条消息) Android Dialog顶部显示+横向全屏+沉浸式效果_AuroraExecue的博客-CSDN博客
以上方式实现沉浸式,有的机型状态栏显示为灰色,需要使用以下方法解决:
(113条消息) Android dialog沉浸式状态栏_pgc_tel的博客-CSDN博客
这其中有两个大坑:
1.BaseActivity里面第二个方法需要去掉setStatusColor,因为这个东西,导致vovix9的状态栏显示异常,会导致我的界面刷新白屏
2.OppoR11在视频会议界面有时候会因为加载时间出现状态栏发白,解决方法,是把设置状态栏和导航栏的代码从onWindowFcousChnaged里面移到OnCreate里面
1.添加主题
//valuse
<style name="TranslucentTheme" parent="AppTheme">
</style>
// values-v19。v19 开始有 android:windowTranslucentStatus 这个属性
<style name="TranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>(可去掉)
</style>
// values-v21。5.0 以上提供了 setStatusBarColor() 方法设置状态栏颜色。
<style name="TranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">true</item>(可去掉)
<!--Android 5.x开始需要把颜色设置透明,否则导航栏会呈现系统默认的浅灰色-->
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
2.在BaseActivity里面添加如下两个方法(第一个方法是为了防止应用标题栏浅色与状态栏傻傻分不清;第二个方法是为了解决有些界面与状态栏分层断截)
3.在标题栏的布局中添加以下属性(防止应用的控件显示在状态栏)
期间遇到一个问题:视频会议界面使用了如下的flag,隐藏了导航栏,和BaseActivity设置的flag组合导致从底部弹出来的dialog下部预留了导航栏高度的空隙
解决方法:去掉了BaseActivity的这个flag