How to change status bar color in android app 2022

This tutorial is about changing the status bar color in an Android application. We will do our best for you to understand this guide. I hope you will like this blog How to change status bar color in android app. If your answer is yes, please share after reading this.

Check how to change status bar color in Android app

Android’s core UI is so beautiful these days that you hardly ever spend time building developer themes. 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 above the Android notification panel header. Best of all, the images change based on the time of day, so you’ll always have a fresh look when checking your notifications.

How to change status bar color in android app

Create a new topic

  • You can follow this method in applications built with Kotlin or Java. It will work on both.
  • Open Android Studio and start a new project by selecting an empty activity. Give it a name of your choice, then select your language and API level. Finally, click Finish.
  • Find an XML file named styles.xml by browsing to res/values/styles.xml.
  • Find another XML file by browsing res/values/colors.xml, and also add the color you want to change for the status bar here.
  • Now in the style.xml file add the following code just before the tag and change the colors as per your choice. ColorPrimaryDark will still be responsible for the color of the status bar.

You can do the same with android:statusBarColor, but it will only work at API level 21 and above. ColorPrimaryDark for statusbar will also not be supported in API level 19. By default, in most API levels, ColorPrimaryDark will be the default color for statusBarColor, so it’s good to change ColorPrimaryDark .

Now go to the manifest/AndroidManifest.xml file and find here the activity for which you want to apply this theme or change the color of the status bar. and add an android:theme=”@style/DemoTheme” attribute. That’s done! Verify your app by running it on an emulator or on a 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. You will need to check the Android API version then run the code. This will not change the color of the status bar below API level 21, but the rest of the code will work fine.

  • After opening Android Studio and creating a new project with an empty activity.
  • Go to res/values/colors.xml and add a color you want to change for the status bar.
  • In your MainActivity, add this code in your onCreate method. Remember to replace the desired color with colorName.
  • Try running your app on an Android emulator or on a physical device. See the changes.

Final words: How to change status bar color in Android app

I hope you understand this article How to change status bar color in android app, if your answer is no, you can ask anything via the contact forum section linked to this article. And if your answer is yes, share this article with your family and friends.

Comments are closed.