How can I make the status bar white with black icons?

AndroidThemes

Android Problem Overview


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?

Android Solutions


Solution 1 - Android

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); 

Solution 2 - Android

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);

Solution 3 - Android

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
            }

Solution 4 - Android

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>

Solution 5 - Android

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}.

Solution 6 - Android

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()

Solution 7 - Android

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

Solution 8 - Android

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.

Solution 9 - Android

I just used this

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

Solution 10 - Android

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>

Solution 11 - Android

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>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJonView Question on Stackoverflow
Solution 1 - AndroidbugraoralView Answer on Stackoverflow
Solution 2 - AndroidRammgarotView Answer on Stackoverflow
Solution 3 - AndroidSerg BurlakaView Answer on Stackoverflow
Solution 4 - AndroidRaphael CView Answer on Stackoverflow
Solution 5 - AndroidAyejuni Ilemobayo KingsView Answer on Stackoverflow
Solution 6 - AndroidGastón SaillénView Answer on Stackoverflow
Solution 7 - AndroidGeorge SamuelView Answer on Stackoverflow
Solution 8 - AndroidKoshView Answer on Stackoverflow
Solution 9 - AndroidMohamed ShakerView Answer on Stackoverflow
Solution 10 - AndroidClean CoderView Answer on Stackoverflow
Solution 11 - AndroidmurtView Answer on Stackoverflow