Android5及以上版本设置状态栏颜色

阅读更多

Android5(LOLLIPOP, API-21)以及以上版本可以设置status bar(状态栏,显示时间和电池信息的地方)颜色

 

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimary));
}

 

refer

How to change the status bar color in android

How to change status bar color to match app in Lollipop

 

 

 

 

 

你可能感兴趣的:(statusbar,lollipop)