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

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

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>

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

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
            }

Tags:

Android

Themes