1

I want to change background color for navigation soft keys that are introduced for Nougat. Is there any way I can implement that? What I already implemented is added navigation bar color in both of my style files. But it's not fixing this and I don't see any changes.

<item name="android:navigationBarColor">@color/navColor</item>

enter image description here

Floern
  • 33,559
  • 24
  • 104
  • 119
Usman Ghauri
  • 931
  • 1
  • 7
  • 26

2 Answers2

1

Use this code

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.MYCOLOR);
        window.setNavigationBarColor(Color.MYCOLOR);
    }
Vaishakh
  • 1,126
  • 10
  • 10
  • Thanks @vaishakh I already solved it though. not this way but though styles. this is programmatic fix but styles seems to be better approach to this – Usman Ghauri Aug 01 '18 at 15:22
1

I fixed this issue by adding these to v21/styles

    <item name="android:navigationBarColor" tools:targetApi="21">@color/colorAccent</item>
    <item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>

and defined this in normal styles.xml file

    <item name="android:navigationBarColor">@color/colorAccent</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>

colorAccent is the accent color I defined for the app

I'm answering this question in case someone might be having the same problem

Usman Ghauri
  • 931
  • 1
  • 7
  • 26