一、设置状态栏颜色
1.调用代码
if (this.getStatusBarTintResource() != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){//6.0及6.0以上用该方法可以改善半透明效果
getWindow().setStatusBarColor(getResources().getColor(getStatusBarTintResource())); }else {if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintResource(color);//在这里可以填写自己需要的颜色 } }
@TargetApi(19)
private void setTranslucentStatus(boolean on) {
Window window = getWindow();
WindowManager.LayoutParams winParams = wind