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
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
}
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}.
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.
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);
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()
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);