美文网首页
android中状态栏变透明的实现方法:

android中状态栏变透明的实现方法:

作者: 写代码的向日葵 | 来源:发表于2021-07-05 15:52 被阅读0次
     protected void setStatusBarTransparent() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                View decorView = getWindow().getDecorView();
                decorView.setOnApplyWindowInsetsListener((v, insets) -> {
                    WindowInsets defaultInsets = v.onApplyWindowInsets(insets);
                    return defaultInsets.replaceSystemWindowInsets(
                            defaultInsets.getSystemWindowInsetLeft(),
                            0,
                            defaultInsets.getSystemWindowInsetRight(),
                            defaultInsets.getSystemWindowInsetBottom());
                });
                ViewCompat.requestApplyInsets(decorView);
                getWindow().setStatusBarColor(ContextCompat.getColor(this, android.R.color.transparent));
            }
        }
    

    相关文章

      网友评论

          本文标题:android中状态栏变透明的实现方法:

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