I want to change the colour of the status bar for my app so that it's white with black icons (instead of the default black with white icons). Is there any way of doing this?
-
Change your default theme – Rohit5k2 Dec 23 '14 at 15:47
-
what theme should I change it to that will change the notification bar icons to black? – Jon Dec 23 '14 at 15:48
-
Use custom theme. To start with see http://stackoverflow.com/questions/8024706/how-do-i-change-the-background-color-of-the-actionbar-of-an-actionbaractivity-us – Rohit5k2 Dec 23 '14 at 15:49
-
so what about apps that follow android guidelines and have white notification icons, how do you expect the user to see them when they are in your app? – tyczj Dec 23 '14 at 15:49
-
@tyczj That's the question - I want them all to become black and stand out on a white background – Jon Dec 23 '14 at 15:52
-
I though he is talking about the Action bar... :( – Rohit5k2 Dec 23 '14 at 15:52
-
yeah thats not going to happen, your app does not have control of the notification bar let alone other apps resources – tyczj Dec 23 '14 at 15:53
-
no - the notification bar. If it can't be done that's also a legitimate answer.. but if there is a way of doing it then it helps me a lot – Jon Dec 23 '14 at 15:53
-
actually the app can control the color of the bar as of Lollipop - see http://stackoverflow.com/questions/22192291/how-to-change-the-status-bar-color-in-android – Jon Dec 23 '14 at 15:55
-
edited the question to change the name of the bar to "status bar" (which is what it turns out it's called) – Jon Dec 23 '14 at 16:02
-
2but you cannot change the color of other apps resources, in fact lollipop makes all icons white no matter what – tyczj Dec 23 '14 at 16:14
14 Answers
With Android M (api level 23) you can achieve this from theme with android:windowLightStatusBar
attribute.
Edit :
Just as Pdroid mentioned, this can also be achieved programatically:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);

- 42,865
- 22
- 93
- 106

- 2,630
- 1
- 21
- 25
-
2
-
@busylee I guess you can create a child of your theme and change it there and apply with activity.getTheme.setTo(Theme another) – bugraoral Oct 20 '15 at 21:34
-
Hi @wrecker i have same issue with my application notification icon. I have added android:windowLightStatusBar=true in my theme and i am testing it in Android M. but the white notification icon not changing to grey when i change the theme using a third party launcher application (Nova Launcher) . I have tried all the possible ways but haven't able to fixed it yet . If you can help me it will be grateful . – Sujit Jun 15 '16 at 07:03
-
@Sujit if other app's icons work but yours fail, there could be a problem with your notification icon – bugraoral Jun 15 '16 at 09:49
-
@wrecker Thanks for your quick response. I got the solution . There is no issue with my code or with notification icon. I checked it in nexus device it is working fine. Only in few samsung device it is not working . – Sujit Jun 15 '16 at 10:17
-
1@busylee Yes you can set it at any time by using following method: View.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); It should be added to the answer – Pdroid Jan 05 '17 at 00:50
-
Is it possible to change the icons color to a custom color (not only black or white)? – JavierSegoviaCordoba Mar 04 '17 at 04:05
-
@Dahnark as far as I know tinting the icons are not supported, and there is a great chance that they will not allow it for system coherince – bugraoral Mar 06 '17 at 10:34
-
8
-
-
How to do the opposite as now with P and above I can dynamically switch between light and dark themes... I can't find the opposite flag or a clear method – Chapz Jan 04 '20 at 21:28
-
@Chapz to revert this, use this value: `View.SYSTEM_UI_FLAG_VISIBLE` (the default) – Daniels Šatcs Apr 23 '20 at 21:21
It is possible to make the white status bar with grey icons e.g. this way for SDK >= 23 (see docs):
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowLightStatusBar">true</item>
</style>
in your styles.xml and set the colorPrimary
to white or programmatically:
getWindow().setStatusBarColor(Color.WHITE);

- 8,084
- 8
- 48
- 62

- 1,467
- 14
- 9
Just added to my activity on Kotlin:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.decorView.systemUiVisibility =View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
window.statusBarColor = Color.WHITE
}

- 2,351
- 24
- 35
this is what worked for me
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowLightStatusBar">true</item>
<item name="android:statusBarColor">@android:color/white</item>
</style>

- 2,296
- 1
- 22
- 22
-
3
-
@Zurmati probably. I don't support anything below api 24 in any of my apps. – Raphael C Dec 30 '21 at 11:46
just add this to you style
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
set android:windowDrawsSystemBarBackgrounds to true*. This is a flag whose description is given below:
Flag indicating whether this Window is responsible for drawing the background for the system bars. If true and the window is not floating, the system bars are drawn with a transparent background and the corresponding areas in this window are filled with the colors specified in {@link android.R.attr#statusBarColor} and {@link android.R.attr#navigationBarColor}. Corresponds to {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS}.

- 448
- 1
- 8
- 18
You can use it this way in Kotlin
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
Make sure to call it in onCreate()
before setContentView()

- 12,319
- 5
- 67
- 77
one of the best solutions you can use:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val decor = this.window.decorView
// valu reflected to set status bar icons in black
if (value) {
decor.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
} else {
// We want to change tint color to white again.
// You can also record the flags in advance so that you can turn UI back completely if
// you have set other flags before, such as translucent or full screen.
decor.systemUiVisibility = 0
}
}
this code is inspired by this comment https://stackoverflow.com/a/37694455/10277217

- 95
- 1
- 9
In your app theme use color for status bar like this
<style name="Theme.YourAppName"
parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/statusBar</item>
<item name="statusBarBackground">@color/statusBar</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">? attr/statusBarBackground</item>
use this code for icon change color
<item name="android:windowLightStatusBar">true</item>
<!-- Customize your theme here. -->
</style>

- 21
- 3
I just used this
- Set the parent in style
parent="Theme.AppCompat.Light.NoActionBar"
- Add this to the menu bar in xml
app:theme="@style/AppThemeWithoutActionBarwithwhitehed"
android:background="#fff"

- 835
- 11
- 25

- 11
- 1
No such way to this unless if you have a control of the whole rom to customize that manually. What i suggest you to do is, use a light gray color for the status bar color through your theme like the google drive does.
Edit: please refer to @Wrekcker answer as this changed in android M.

- 6,140
- 3
- 36
- 67
I achieved it using:
if (Build.VERSION.SDK_INT >= 19 && Build.VERSION.SDK_INT < 21) {
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, true);
}
if (Build.VERSION.SDK_INT >= 19) {
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false); }
if (Build.VERSION.SDK_INT >= 21) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
getWindow().setStatusBarColor(Color.WHITE);
}
setContentView(R.layout.activity_mainss);
Theme is set in AndroidManifest:
<style name="Theme.MapRiti" parent="Theme.AppCompat.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryDark">@color/orange</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
</style>

- 496
- 5
- 12
In your app theme use color for status bar like this @color/statusBar color is in color file ?attr/statusBarBackground this code is for setting status bar color automatically when light mode flag is called..
true and this code of flag is for changing the icon's color to dark when light mode flag is called
this thing worked for me

- 21
- 3
There are two approaches we can take.
1. Dynamically:
fun Activity.setStatusBarColorAndAppearance(statusBarColor: String, isLight: Boolean ) {
try {
window.statusBarColor = (Color.parseColor(statusBarColor))// Or we can use from resource color: ContextCompat.getColor(mContext, R.color.colorPrimary)
WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightStatusBars = isLight
} catch (e: Exception) {
e.printStackTrace()
}
}
And use it inside the onCreate()
method:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStatusBarColorAndAppearance("#5e5c64", false)
....
}
2. By xml:
Use this in AppTheme
<item name="android:windowLightStatusBar">false</item>
<item name="android:statusBarColor">@color/colorPrimary</item>
Note: Tested above 8.0.

- 8,830
- 18
- 51
- 70
I had the same issue.
I noticed that when I use normal layout like RelativeLayout it doesn't work. But when I switched to that come from support library like CordinatorLayout it has finally started to work. Try this.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Activities.Activity">
<android.support.v7.widget.Toolbar
android:id="@+id/tb_activity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CoordinatorLayout>
<********* BELOW OTHERS ATTRIBUTES ************>
styles
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
And in the manifest
<activity
android:name=".Activities.MyActivity"
android:label="Activity"
android:theme="@style/AppTheme.NoActionBar">
</activity>

- 3,790
- 4
- 37
- 48