How to Change the Color of Status Bar in an Android App – Guide

Android’s main UI looks so good these days that you almost never waste time creating themes for developers. But even with the beauty of Material Design working in our favor now, there’s always room for improvement, isn’t there? Recently, developer Thunder07 created an Xposed module that overlays beautiful images on the header of Android’s notification panel. Even better, the photos change based on the time of day, so you always have a fresh, up-to-date image when you check your notifications.

How to Change the Status Bar Color in an Android App

Creating a new theme

You can do the same with android:statusBarColor, but it will only work at API level 21 above. ColorPrimaryDark for the status bar will also not support API level 19. By default, at most API levels, ColorPrimaryDark will be the default color for statusBarColor, so it’s good to change ColorPrimaryDark. Now access the manifest/AndroidManifest.xml and here search for the activity to which you want to apply that theme or change the color of the status bar. and add an attribute android:theme=”@style/DemoTheme”. It’s done! Verify your app by running it on an emulator or physical device.

Using the setStatusBarColor method

This method can only be used at API level 21 above. Officially, the status bar color is not supported by API level 21. Although, here we added an if condition, because in case you have not selected above or equal to API 21, then it will check Android API version and then execute code. It won’t change the status bar color below API level 21, but the remaining code will work fine.

Final note

I hope you like the guide How to Change the Color of Status Bar in an Android App. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.