1.顶部状态栏黑条问题
解决方案①:
在Activuty的onCreate方法中设置如下代码。
WindowManager.LayoutParams lp = getWindow().getAttributes();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().setAttributes(lp);
}
解决方案②:
在主题属性中加入如下属性。
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
2.顶部状态栏灰条问题
解决方案①:
在Activuty的onCreate方法中设置如下代码。
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
解决方案②:
在主题属性中加入如下属性。
<item name="android:windowTranslucentStatus">true</item>
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » 安卓沉浸式状态栏遇到的问题
发表评论 取消回复