NavigationView布局
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="@dimen/navigationView_width"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true"
android:background="@color/nav_item_bg"
app:itemBackground="@drawable/nav_item_selector"
app:headerLayout="@layout/nav_header_main"
app:itemTextAppearance="@style/itemTextAppearance"
app:menu="@menu/activity_main_drawer"/>
app:itemBackground="@drawable/nav_item_selector" 加上这句就可以了。
nav_item_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="@color/item_selected_bg"/>
</shape>
</item>
<item android:state_focused="true">
<shape>
<solid android:color="@color/item_selected_bg"/>
</shape>
</item>
<item android:state_pressed="false">
<shape>
<solid android:color="@color/nav_item_bg"/> //填充的颜色
</shape>
</item>
</selector>