Navigation View. android.support.design:itemIconTint ,android.support.design:itemTextColor xml attributes not working

Danfoa picture Danfoa · Jul 8, 2015 · Viewed 7.5k times · Source

The new Navigation View provided in the support library for using the material design, int changing the xml parameters: - android.support.design:itemIconTint - android.support.design:itemTextColor I've found in the Class reference that this parameters can change through java coding but i want to do it in the xml file, nevertheless it dosnt work i dont know what im doing wrong.

Here is My Navigation Drawer and Navigation View XML

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android.support.design="http://schemas.android.com/tools"
android:fitsSystemWindows="true">

<RelativeLayout
    --- content 
 </RelativeLayout>

<android.support.design.widget.NavigationView
    android:layout_width="280dp"
    android:layout_height="match_parent"
    android:id="@+id/navigationView"
    android:layout_gravity="start"
    android.support.design:itemIconTint="@color/navigation_view_color_set"
    android.support.design:itemTextColor="@color/navigation_view_color_set"
    app:headerLayout="@layout/navigation_view_header"
    app:menu="@menu/menu_data"/>

And my ColorStateList in a subdirectory of .res, named color.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:color="@color/primary"/>
    <item android:state_pressed="true" android:state_enabled="false" android:color="@color/primary_dark" />
    <item android:state_enabled="false" android:color="@color/primary_dark" />
    <item android:color="@android:color/white"/>
</selector>

I don`t know whats going wrong, and i cant find any documentation using this xml parameters.

what I what to accomplish.

  1. Changing state color for items and icons
  2. Changing the navigation Background

http://www.google.com/design/spec/patterns/navigation-drawer.html#navigation-drawer-content

Answer

Moinkhan picture Moinkhan · Jul 8, 2015

You may have to try this instead of android.support.design:itemIconTint

app:itemIconTint="@color/navigation_view_color_set"
app:itemTextColor="@color/navigation_view_color_set"