沉浸式

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //透明导航栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            View contentView=getWindow().findViewById(Window.ID_ANDROID_CONTENT);
            contentView.setBackgroundColor(getResources().getColor(R.color.app_theme_color));
            contentView.setPadding(0, DensityUtils.dip2px(getBaseContext(),20),0,0);
        }
原文地址:https://www.cnblogs.com/g-sheng/p/5814866.html