1

It is my first time programming in android and I want to change the color of the bars, I read the documentation it seems simple but it does not work for me. I am going to show what I add but if you need more information I will post it.

    Window window = getWindow();
    window.setStatusBarColor(R.color.colorWhite);
    window.setNavigationBarColor(R.color.colorWhite);

All it does is clarify the bar

enter image description here

2 Answers2

0

From java class:

Get color by calling resources, do this way:

Window window = getWindow();
window.setStatusBarColor(getResources().getColor(R.color.colorWhite));
window.setNavigationBarColor(getResources().getColor(R.color.colorSome));

This color can be changed from your AppTheme in styles.xml file. It's value can be changed from attribute <item name="colorPrimaryDark">#yourColor</item>

styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Their colors are available in colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#3F51B5</color>
    <color name="colorPrimaryDark">#303F9F</color>
    <color name="colorAccent">#FF4081</color>
</resources>

Read the documentation.

Rajasekhar
  • 1,297
  • 2
  • 10
  • 19