Change Navigation View Item Color Dynamically Android

I’d like to build a navigation drawer where each item has a different selection color (the icon tint and text color) as the google play store has:

enter image description here

  • Dynamically creating Buttons and setting onClickListener
  • Executing Groovy scripts embed in Java on runtime for Android
  • Android EditText and Button on same line
  • How can I view the shared preferences file using Android Studio?
  • Screenshot of the Nexus One from adb?
  • How to create UUID from string in android
  • I’m not sure how they’ve solved this, I think they use different activities with different drawers. I want to use fragments and I want to change the icon tint and text color. Any ideas how I can do this? I’m using google’s design support library and a drawer layout with a navigation view in there.

    Related posts:

    Dagger- Should we create each component and module for each Activity/ Fragment
    android in app billing purchase verification failed
    Re-initializing Twitter Fabric after long idle time android app
    how to use LocalBroadcastManager?
    Libgdx app.exit() on Android not closing application
    Android studio error when add java8 support
  • no gravity for scrollview. how to make content inside scrollview as center
  • How to startForeground() without showing notification?
  • Gradle error: Minimum supported Gradle version is 3.3. Current version is 3.2
  • Android multi-touch interference
  • How can write code to make sharedpreferences for array in android?
  • Android Facebook authorization - can not log in when official Facebook app is installed
  • 4 Solutions collect form web for “Change Navigation View Item Color Dynamically Android”

    use app:itemIconTint in your NavigationView for icons and use app:itemTextColor for textColors

    Sample :

    drawable/navigation_text_color :

    <selector xmlns:android="">
        <!-- This is used when the Navigation Item is checked -->
        <item android:color="#009688" android:state_checked="true" />
        <!-- This is the default text color -->
        <item android:color="#E91E63" />

    and layout :


    If by dynamically you mean programmatically you could try this:

    int[][] states = new int[][]{
            new int[]{-android.R.attr.state_checked},  // unchecked
            new int[]{android.R.attr.state_checked},   // checked
            new int[]{}                                // default
    // Fill in color corresponding to state defined in state
    int[] colors = new int[]{
    ColorStateList navigationViewColorStateList = new ColorStateList(states, colors);
    // apply to text color
    // apply to icon color

    So you could define multiple colors for different settings like Day or Night.

    Finllay i got the answer,

    You must change the colorAccent in the colors file to which ever color you want :

      <color name="colorAccent">whichever color required</color>

    This solution worked for me

               app:itemIconTint="@color/your_selector_file_name" // for Icon
            app:itemTextColor="@color/your_selector_file_name" // for text

    Adding to what @DAVOOD said. The below color selector worked for me.

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="">
            <!-- This is used when the Navigation Item is checked -->
            <item android:color="@color/tenoBrandColor" android:state_pressed="true" />
            <!-- This is the default text color -->
            <item android:color="@color/textprimary" />
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.