美文网首页
刘海屏隐藏状态栏,导航栏,沉浸式适配。

刘海屏隐藏状态栏,导航栏,沉浸式适配。

作者: CLBAdai | 来源:发表于2019-07-01 19:03 被阅读0次

这里只有代码 要学习请看源码。觉得有用可以点个赞。

//开启全面屏模式
public void openFullScreenModel() {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; //设置绘图区域可以进入刘海屏区域
        getWindow().setAttributes(lp);
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);
    }

相关文章

网友评论

      本文标题:刘海屏隐藏状态栏,导航栏,沉浸式适配。

      本文链接:https://www.haomeiwen.com/subject/fccbwxtx.html