Candy Navigation Bar Color

In my application, I need to change the color of the bottom navigation bar. I watched a lot of posts, but could not find a solution. I am using the appCompat library. Need help please. Thanks in advance.

enter image description here

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> 
+61
android android-5.0-lollipop colors navigationbar
Jan 08 '15 at 11:30
source share
5 answers

This can be done inside styles.xml using

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

or

 window.setNavigationBarColor(@ColorInt int color) 

http://developer.android.com/reference/android/view/Window.html#setNavigationBarColor(int)

Please note that this method was introduced in Android Lollipop and will not work on API version <21.

The second method (works in KitKat) is to set windowTranslucentNavigation to true in the manifest and place the color view under the navigation bar.

+94
Jan 08 '15 at 11:34
source share

Here's how to do it programmatically:

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

Using the socket library:

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

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

 <item name="android:navigationBarColor">@color/your_awesome_color</item> 
+48
Apr 08 '15 at 12:22
source share

There are several ways to change the color of the navigation bar.

<strong> values-V21 / style.xml

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

<strong> values ​​/style.xml

 <resources xmlns:tools="http://schemas.android.com/tools"> <item name="android:navigationBarColor" tools:targetApi="21">@color/navigationbar_color</item> 

You can also change the color of the navigation bar using Programming .

  if (Build.VERSION.SDK_INT >= 21) getWindow().setNavigationBarColor(getResources().getColor(R.color.navigationbar_color)); 

Using the compatibility library -

 if (Build.VERSION.SDK_INT >= 21) { getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.primary)); } 
+22
Sep 04 '15 at 23:16
source share

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

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

+8
Jul 15 '15 at 11:34
source share

You can change it directly in styles.xml : \ app \ src \ main \ res \ values ​​\ styles.xml

This work on older versions, I changed it in KitKat and came here.

0
Sep 21 '17 at 14:26
source share



All Articles