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>

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部