Issue
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?
Solution
Just add this line:
<item android:drawable="@drawable/icon_milestone_selected" android:state_pressed="false" state_activated="true"/>
It should work.
Answered By - romtsn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.