Change text color of navigation item

How can I change the menu text in the navigation menu. My menu.xml file, I also write

Application: itemIconTint = "@ color / white" app: itemTextColor = "@ color / white" in my layout, but this will not work

<?xml version="1.0" encoding="utf-8"?> 

 <item android:checked="false" android:title="@string/popular"> <menu> <item android:id="@+id/tag1" android:checked="false" android:icon="@drawable/bird" android:title="@string/tag1" /> <item android:id="@+id/tag2" android:checked="false" android:icon="@drawable/rabbit" android:title="@string/tag2" /> <item android:id="@+id/tag3" android:checked="false" android:icon="@drawable/bird" android:title="@string/tag3" /> <item android:id="@+id/tag4" android:checked="false" android:icon="@drawable/rabbit" android:title="@string/tag4" /> <item android:id="@+id/tag5" android:checked="false" android:icon="@drawable/bird" android:title="@string/tag5" /> <item android:id="@+id/setting" android:checked="false" android:icon="@drawable/setting" android:title="@string/setting" /> <item android:id="@+id/rate" android:checked="false" android:icon="@drawable/rating" android:title="@string/rate" /> </menu> </item> 

Here is my NavigationView in my application, as you can see that there are no effects if itemTextColor

my NavigationView as ..

  <android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:background="@color/theme_primary" app:headerLayout="@layout/layout_drawer_header" app:itemIconTint="@color/white" app:itemTextColor="@color/white" app:menu="@menu/menu_main" /> 
+8
android android-navigationview
source share
3 answers

Thanks for the answer, I just searched a bit and I found the answer that there are no changes in the style, I just change in the JAVA file, like everything.

 NavigationView navigation_view = (NavigationView) findViewById(R.id.navigation_view); navigation_view.setItemTextColor(ColorStateList.valueOf(Color.BLACK)); navigation_view.setItemIconTintList(null); 
+4
source share

NavigationView uses the theme color Widget.Design.NavigationView . You can redefine this topic as follows.

Create your own style that overrides Widget.Design.NavigationView in your .xml style:

 <style name="NavigationStyle" parent="Widget.Design.NavigationView"> <item name="android:textColorPrimary">@color/white</item> <item name="android:textColorSecondary">@color/white</item> </style> 

Use this theme in your XML layout file:

 <android.support.design.widget.NavigationView ... android:theme="@style/NavigationStyle" ... /> 
+1
source share

Please check it.

 android:id="@+id/nav_view" android:background="@drawable/login_bg" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:itemIconTint="#ffffff" app:theme="@style/NavigationDrawerStyle" app:itemTextColor="@color/white" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> 

You can also add a style to the navigation item. `

  <item name="android:textColorSecondary">#4dffffff</item> <item name="android:dividerHeight">0.5dp</item> <item name="android:listDivider">@color/white_with_alpha</item> <item name="android:textSize">18dp</item> </style>` 
0
source share

All Articles