Android4.4以上沉浸式状态栏

在BaseActivity的onCreate中添加如下代码,设置状态栏透明和设置状态栏颜色

 if (Build.VERSION.SDK_INT >= 19) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            StatusBarCompat.compat(this, getResources().getColor(R.color.color_blue));
            View view = ((ViewGroup)this.findViewById(android.R.id.content)).getChildAt(0);
            ViewGroup group = (ViewGroup)view;
            group.setClipToPadding(true);
            group.setFitsSystemWindows(true);
        }


你可能感兴趣的:(android,沉浸式状态栏)