android 切换状态栏图标颜色(黑白)
public void changStatusIconCollor(boolean setDark) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
View decorView = getWindow().getDecorView();
if(decorView != null){
int vis = decorView.getSystemUiVisibility();
if(setDark){
vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
} else{
vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
decorView.setSystemUiVisibility(vis);
}
}
}
设置状态栏背景全透明
public class activityUtil {
public static void setStatusBarTransparentColor(Activity activity)
{
//设置全透明状态栏
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);//半透明
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
}
}