Change Android Activity Status Bar Color like a Pro

Mudit Sen
2 min readAug 18, 2021

--

Well, you have probably already changed color of your application’s Status Bar a lot times before. But probably faced few issue around when changing theme of whole applications or sometimes when small notification icons are not visible because the status bar is too Light in color or too Dark in color.

So how to resolve these issues by single method when changing the color of the status bar?

Here is how.

Create a class Extenstions.kt if not already created. Then in that file add these few methods.

Then in your activity call like :

setStatusBarColor(Color.parseColor(“#55efc4”))

And in your Fragment like

activity?.setStatusBarColor(Color.parseColor(“#55efc4”))

Explanation: Well, both method are fairly easy to understand. isColorDark checks if the color is Dark Enough. And setStatusBarColor accepts color as parameter then check if the color is Dark then set the theme of status bar to Dark so the small icons visible White and vice versa.

Github Profile:

Follow:

--

--