Reputation: 260
I want to change the color of the item in my navigation drawer which is currently enabled. I want that on my Home Activity, the item (Home) in the navigation drawer is colored blue, the oder 2 items (settings, about) rest black... How can I manage to do that?
Upvotes: 1
Views: 936
Reputation: 2474
used below the drawer for changing selection & back color.
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_gravity="start"
android:background="@color/colorPrimaryDark"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_home"
app:itemBackground="@drawable/drawer_selected_item"
app:itemIconTint="@color/drawer_item"
app:itemTextAppearance="@style/NavDrawerTextStyle"
app:itemTextColor="@color/drawer_item"
app:menu="@menu/activity_home_drawer">
put below code in drawable resource. drawer_selected_item.xml file.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/white" android:state_checked="true" />
<item android:drawable="@android:color/transparent" />
</selector>
put below file in color resource. drawer_item.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimaryDark" android:state_checked="true" />
<item android:color="@color/white" />
</selector>
Upvotes: 1
Reputation: 86
to change the color use this app:itemIconTint="@android:color/blue" you can change the blue to any color you want.
Upvotes: 0