Android Lollipop Set Status Bar Text Color
For Android 6.0 and above You can check Sunita's answer.
Android 5.0
we are able to change only status bar color not status bar text color.
there is no method like
setStatusBarTextColor(getResources().getColor(R.color.orange));
In short, it's not possible on Android 5.0. Check this answer
Here's a Java implementation of Gandalf458's answer.
/** Changes the System Bar Theme. */
@RequiresApi(api = Build.VERSION_CODES.M)
public static final void setSystemBarTheme(final Activity pActivity, final boolean pIsDark) {
// Fetch the current flags.
final int lFlags = pActivity.getWindow().getDecorView().getSystemUiVisibility();
// Update the SystemUiVisibility dependening on whether we want a Light or Dark theme.
pActivity.getWindow().getDecorView().setSystemUiVisibility(pIsDark ? (lFlags & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) : (lFlags | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR));
}
You can not set the status bar text color by specifying any color explicitly
But you can try below alternative which is Added in API 23,
You can use "android:windowLightStatusBar" attribute in two ways
- "android:windowLightStatusBar" = true, status bar text color will be compatible (grey) when status bar color is light
- "android:windowLightStatusBar" = false, status bar text color will be compatible (white) when status bar color is dark
<style name="statusBarStyle" parent="@android:style/Theme.DeviceDefault.Light"> <item name="android:statusBarColor">@color/status_bar_color</item> <item name="android:windowLightStatusBar">false</item> </style>
You can check above api in below link - https://developer.android.com/reference/android/R.attr.html#windowLightStatusBar