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