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

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?


Solution 1:

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:

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:

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:

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:

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