I am Struggling to change the color of the status bar for each activity.
I have tried the create theme and style listed in posts on this site to no avail.
How can I make each activity have a status bar of different color?
You can change it by setting the android:statusBarColor
or android:colorPrimaryDark
attribute of the style you're using for your app in styles.xml
.
(android:statusBarColor
inherits the value of android:colorPrimaryDark
by default)
For example (since we're using an AppCompat
theme here, the android namespace is omitted):
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">@color/your_custom_color</item>
</style>
On API level 21+ you can also use the Window.setStatusBarColor()
method from code.