I am using android NavigationView. I want to give seperate icon color for some items in the NavigationView, not for all items. I hope each icon have different color. How can I do this?
Asked
Active
Viewed 565 times
2
-
You need to add the color in theme: http://stackoverflow.com/questions/31626488/change-the-color-of-navigation-drawer-indicator-icon – anoopg87 Dec 15 '15 at 10:38
2 Answers
0
You can try this
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_home"
app:menu="@menu/activity_home_drawer" />
and the menu
<?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_inbox"
android:icon="@null"
android:title="@string/inbox" />
<item
android:id="@+id/nav_start_end"
android:icon="@null"
android:title="@string/start_trip" />
<item
android:id="@+id/nav_map"
android:icon="@null"
android:title="@string/showmapview" />
<item
android:id="@+id/nav_allstudentlist"
android:icon="@null"
android:title="@string/allstudentlist" />
<item
android:id="@+id/nav_settings"
android:icon="@null"
android:title="@string/settings" />
</group>
</menu>
you can specify your icons for each menu

anoopg87
- 82
- 6
-
Thanks,I do it ,but the icons have a same color.if you set app:itemIconTint="your color" attribute in NavigationView,the problem is still unsolved.Because the icons still have a same color. – 牙奕集 Dec 15 '15 at 10:20
0
If you are referring to Drawable/Mipmap resource for Icon, it depends on what colour those originally are in I assume. If you are importing the images into Android Studio through the menu as ActionBar icons those would all be in one colour based on what you selected as theme (Light/Dark)
Are your assets (drawables) having different colours?

prasunnair
- 92
- 3
- 12
-
I use drawable resource for icon in NavigationView menu item by " android:icon="@drawable/ic_home" ". But no matter what the icon is, the color is same. – 牙奕集 Dec 15 '15 at 15:39