Android lollipop change navigation bar color


Answers

Here is how to do it programatically:

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {                
   getWindow().setNavigationBarColor(getResources().getColor(R.color.your_awesome_color));
}

Using Compat library:

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.primary));
}

Here is how to do it with xml in the values-v21/style.xml folder:

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

In my app I need to change the bottom navigation bar color. I watched many post but cant find with the solution. I am using appCompat library. Need help please. Thanks in advance.

v21/styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light">
       <item name="android:windowBackground">@drawable/bgpreview</item>
       <item name="android:colorPrimary">@color/MyColor</item>
       <item name="android:colorPrimaryDark">@color/MyColor</item>
       <item name="android:windowContentOverlay">@null</item>
       <item name="android:textColorPrimary">@color/MyColor</item>
       <item name="colorAccent">@color/MyColor</item>
       <!-- darker variant for the status bar and contextual app bars -->
       <item name="android:windowContentTransitions">true</item>
       <item name="android:windowAllowEnterTransitionOverlap">true</item>
       <item name="android:windowAllowReturnTransitionOverlap">true</item>
       <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
       <item name="android:windowSharedElementExitTransition">@android:transition/move</item>

       <item name="windowActionBar">false</item>
       <item name="android:textAllCaps">false</item>

</style>



android change navigation bar color

You can do it by adding this statement in styles

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

or this in the main java

window.setNavigationBarColor(@ColorInt int color);



Change Android nav bar buttons colour

you can do this in API > 21 as follow :

if (Build.VERSION.SDK_INT >= 21) {
    getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.some_color));
}

see more information here


or just add following code in values-v21/style.xml

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



check my previous Answer it will definitely help you get the result.

You can achieve this in two ways- either using style or Activity.

values-v21/style.xml

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

Using Compat Library in Activity-

if (Build.VERSION.SDK_INT >= 21) {
    getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.primary));
}



You can add the following line in the values-v21/style.xml folder:

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