Arya R. Arya R. - 3 months ago 32
Android Question

Change specific icon's color in NavigationDrawer Android

I have a problem with changing the icon's color in default Drawer Menu in android, there are lots of topics but they only explain changing the tint color of whole menu not a specific icon:

Menu Items

I would like to change the color of

Favorites
icon to yellow

Answer

You can change icon of the menu from here like this from activity_drawer_drawer.xml layout

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android">

        <group android:checkableBehavior="single">
            <item
                android:id="@+id/nav_camera"
                <!-- Change your drawable here -->
                android:icon="@drawable/ic_menu_camera"
                android:title="Import"/>
            <item
                android:id="@+id/nav_gallery"
                android:icon="@drawable/ic_menu_gallery"
                android:title="Gallery"/>
            <item
                android:id="@+id/nav_slideshow"
                android:icon="@drawable/ic_menu_slideshow"
                android:title="Slideshow"/>
            <item
                android:id="@+id/nav_manage"
                android:icon="@drawable/ic_menu_manage"
                android:title="Tools"/>
        </group>

        <item android:title="Communicate">
            <menu>
                <item
                    android:id="@+id/nav_share"
                    android:icon="@drawable/ic_menu_share"
                    android:title="Share"/>
                <item
                    android:id="@+id/nav_send"
                    android:icon="@drawable/ic_menu_send"
                    android:title="Send"/>
            </menu>
        </item>

    </menu>

To remove tint color effect use this

mNavigationView.setItemIconTintList(null);
Comments