public void setDarkStatusIcon(boolean bDark) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
View decorView = getWindow().getDecorView();
getWindow().setStatusBarColor(getResources().getColor(android.R.color.white));//这里对应的是状态栏的颜色,就是style中colorPrimaryDark的颜色
if(decorView != null){
int vis = decorView.getSystemUiVisibility();
if(bDark){
vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
} else{
vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
decorView.setSystemUiVisibility(vis);
}
}
}
网友评论