I have searched all things and experimented but not luck with NavigationView
.
itemIconTint
, itemTextColor
and itemBackground
working with ripple
effect. but problem is state selected
not working in selector drawable
I have also created drawable-v21
and put ripple_navigation_selector.xml
My goal is when open drawer again previous selected item should be in yellow color eg. Notifications item
NavigationView
inside main_layout.xml
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@color/black"
app:headerLayout="@layout/header"
app:itemIconTint="@drawable/navigation_view_icon_tint_selector"
app:itemTextColor="@drawable/navigation_view_text_selector"
app:menu="@menu/drawer"
app1:itemBackground="@drawable/ripple_navigation_selector"
/>
ripple_navigation_selector.xml
inside drawable-v21
<item
android:id="@android:id/mask"
android:drawable="@drawable/navigation_selector"/>
<item android:drawable="@drawable/navigation_selector"/>
navigation_selector.xml
inside drawable-v21
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@color/left_light_yellow" android:state_pressed="true"></item>
<item android:drawable="@color/left_light_yellow" android:state_activated="true"></item>
<item android:drawable="@color/left_light_yellow" android:state_checked="true"></item>
<item android:drawable="@android:color/black"></item>
color string named left_light_yellow
<color name="left_light_yellow">#F6CE20</color>
I think you have to make your menu items checkable
<item
android:id="@+id/wishlist"
android:checkable="true"
android:title="Wishlist" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With