0

so I would like to change the status bar color in my app to the value #65BC8D.

In the previous Android Studio versions I could change it in the Theme Editor but how do I change it directly in the styles.xml?

Diogo Sequeira
  • 126
  • 1
  • 9
  • Possible duplicate of [How to change the status bar color in android](https://stackoverflow.com/questions/22192291/how-to-change-the-status-bar-color-in-android) – msal Mar 04 '19 at 16:21

2 Answers2

1

Mostly this is the colorPrimaryDark value if you are using the standard Material theme provided in the AppCompat themes. You can change that value to the hex value you want. E.g.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimaryDark">#65BC8D</item>
</style>

https://developer.android.com/guide/topics/ui/look-and-feel/themes#CustomizeTheme

Also take a look at the following picture (taken from https://forum.xda-developers.com/android/help/changing-colorprimary-colorprimarydark-t3813991) for a reference:

enter image description here

gi097
  • 7,313
  • 3
  • 27
  • 49
0

If you want to do it programatically then you can use,

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window window = activity.getWindow();

// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

// finally change the color
window.setStatusBarColor(ContextCompat.getColor(activity,R.color.my_statusbar_color));
};

Source - Change status bar color in Android