Reputation: 2535
I am trying to change the icon of a nav drawer item when it is selected. I prepared the following file for the same:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/icon_milestone_selected" android:state_pressed="true"/>
<item android:drawable="@drawable/icon_milestone_selected" android:state_focused="true"/>
<item android:drawable="@drawable/icon_milestone_static"/>
</selector>
However the icon only changes when its touched, when the nav drawer is dismissed and opened again it does not give me the changed icon. What am I missing here?
Upvotes: 1
Views: 2794
Reputation: 11982
Just add this line:
<item android:drawable="@drawable/icon_milestone_selected" android:state_pressed="false" state_activated="true"/>
It should work.
Upvotes: 2