D
D
dchuvasov2016-04-22 14:40:09
Android
dchuvasov, 2016-04-22 14:40:09

How to change the statusbar color?

Tell me which way to dig. You need to change the shading color of the statusbar depending on the fragment. The status bar itself is transparent

<item name="android:statusBarColor">@android:color/transparent</item>
And by default, when you collapse the CollapsingToolbarLayout , it goes into the theme color colorPrimaryDark. How can I keep this behavior but change the shading color?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dchuvasov, 2016-04-25
@dchuvasov

The CollapsingToolbarLayout has a setStatusBarScrim method that sets the color. But as I understand it, this method does not set the color of the statusbar, but draws a background on the CollapsingToolbarLayout itself.

N
Nikita Rusin, 2016-04-23
@rusinikita

public static void setStatusBarColor(Activity activity, @ColorRes int color) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      activity.getWindow().setStatusBarColor(activity.getResources().getColor(color));
    }
}

But on the screen where I use it, there is no CollapsingTooolbar. If you dig in this direction, you may need to add some flags.
If you google how to dynamically change something from the code, use the word programmatically

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question