如何还原默认状态栏颜色? [英] How can I restore the default status bar color?
问题描述
在我的一项活动中,我不希望状态栏显示任何颜色.我希望它保持在我的应用运行之前的任何颜色.
我可以将其更改为黑色,但是黑色不是默认设置,默认设置是透明的.我不想试图找到哪种透明度是正确的,因为在其他人的手机上透明度可能有所不同,所以我基本上不想在此特定活动中使用状态栏的颜色功能
if(Build.VERSION.SDK_INT> = Build.VERSION_CODES.LOLLIPOP){窗口window = getWindow();window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);window.setStatusBarColor(Color.BLACK);}
默认情况下,标题栏使用 colorPrimaryDark
(文档
In one of my activities, I don't want the status bar to have any color. I want it to stay in whichever color the is before my app is ran.
I can change it to black, but black isn't the default, the default is kind of transparent. I don't want tot try to find which transparency is the correct one because It might be different on other people's phones so I want to basically not use the color feature of the status bar in this particular activiy
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.BLACK);
}
By default title bar is colored using colorPrimaryDark
(docs here, see pic below). Or when you look at Material theme:
<item name="statusBarColor">?attr/colorPrimaryDark</item>
You should also see this posts
- https://chris.banes.me/2014/10/17/appcompat-v21/
- http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html
这篇关于如何还原默认状态栏颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!