Answer the question
In order to leave comments, you need to log in
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
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.
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));
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question