Is there a way to add a pressed state to an ImageView? I have an image that i place a click listener on, and when I press it I want to change to imageview src for a second to mimic the pressed state of buttons or listview items.
Can I add a selector xml to the src attribute?
Figured it out. You CAN add a selector xml to your src attribute of an ImageView. In my case, i created "addbuttonbg.xml" in my drawables:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/quickaddbutton" /> <item android:state_pressed="true" android:drawable="@drawable/quickaddbutton_click" /> <item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/quickaddbutton" /> </selector> Then set your imageview src to @drawable/addbuttonbg