Gaurav Mandlik Gaurav Mandlik - 3 months ago 32
Android Question

change Item text color of NavigationView

How can i change NavigationView menu item text color.My menu.xml file is, i also write


app:itemIconTint="@color/white"
app:itemTextColor="@color/white" in my layout but it 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 app as you can see there is no any effects if itemTextColor

my NavigationView like..

<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" />

Answer

thanks for the response, i just search little and i found the answer there is no any style changes, i just change in JAVA file like and it's done.

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