I have a NavigationView, with many items in it.
I'm trying to change the background of the selected (checked) item. I have a selector that changes the itemTextColor and that works fine.
I have a drawable resource:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/selected_item_accent"/>
</shape>
And my selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/nav_view_background" android:state_checked="true" />
<item android:drawable="@drawable/nav_view_background" android:state_pressed="true" />
<item android:drawable="@android:color/transparent" />
</selector>
And lastly the NavigationView
<android.support.design.widget.NavigationView
android:id="@+id/navView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/window_background"
app:itemTextColor="@drawable/selector_nav_view_text"
app:itemBackground="@drawable/selector_nav_view_background"
app:headerLayout="@layout/app_nav_header" />
The pressed state works as expected, but the selected item background does not change.
I'm wondering what I'm doing wrong here. Thanks.