Make it a toggle button instead of an image. And then create a selector in xml with the different images you want in each matching state. (I'm not sure if this can also be done using imageView, why I told you to use the toggle button).
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/button_pressed"/> <item android:state_pressed="false" android:drawable="@drawable/button_rested"/> <item android:state_enabled="false" android:drawable="@drawable/button_disabled"/> </selector>
on the bar
<ToggleButton android:id="@+id/image" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@null" android:gravity="center_horizontal" android:src="@drawable/button_selector"/>
source share