I'm trying to set the status bar text color in Android v21, but I'm not seeing an API method for it. Here's what I have so far for the background
MyActivity.java > onCreate:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(getResources().getColor(R.color.white)); }
Obviously white text on white background won't work. I'm looking for something like
window.setStatusBarTextColor(getResources().getColor(R.color.orange));
Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method.
Probably the best option for non-rooted (and also rooted users, if you enjoy simplicity), Material Notification Panel allows you to completely customize the notification panel with colors, transparency, background photos, and icon style – if you have a Nougat phone but want Oreo notification panel icons, for example, ...
To customize it, first pull down the slider bar from the top of the screen. Next, tap on the three vertical dots in the top right corner. Now click on Status bar. You're in.
Just go to res/values/styles.edit the xml file to change the color of action 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
<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
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)); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With