Rahul Gala
Rahul Gala

Reputation: 113

How to add custom images with color to menu items?

I Have Following Menu Items In My Navigation Drawer

<item
        android:id="@+id/nav_home"
        android:icon="@drawable/home"
        android:title="Home" />
    <item
        android:id="@+id/nav_gallery"
        android:icon="@drawable/gallery"
        android:title="Gallery" />
    <item
        android:id="@+id/logout"
        android:icon="@drawable/logout"
        android:title="Slideshow" />

I have images(.png) of the icons I tried putting it in the menu item but it comes in grayscale.

How do I put the exact image (with color) as the icon of menu item ?

Upvotes: 1

Views: 926

Answers (1)

Raj
Raj

Reputation: 194

You can add custom layout to the navigation drawer menu item. Place the image in ImageView of custom_layout and check it:

<item
        android:id="@+id/nav_custom_layout"
        app:actionLayout="@layout/custom_layout"
        app:showAsAction="always"
        tools:ignore="MenuTitle"/>

Upvotes: 2

Related Questions