create a selector
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/primary" android:state_checked="true" />
<item android:drawable="@android:color/transparent" />
</selector>
and set
app:itemBackground="@drawable/nav_view_item_background"
then the selected item will be highlighted.
if you want to change the text color then set
app:itemTextColor="@drawable/nav_view_item_textcolor"
and create a selector for it like
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/white" android:state_checked="true" />
<item android:color="@color/primary" />
</selector>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…