Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I restore the default status bar color?

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);
 }
like image 381
code511788465541441 Avatar asked Oct 18 '25 05:10

code511788465541441


1 Answers

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

enter image description here

like image 108
Marcin Orlowski Avatar answered Oct 19 '25 20:10

Marcin Orlowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!