当statusbar为白色时候,设置状态栏字体图标反色(即变黑色)

  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);
        }
    }
}

你可能感兴趣的:(当statusbar为白色时候,设置状态栏字体图标反色(即变黑色))