用xml来定义imagebutton的状态
res/drawable/drawable_x.xml
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/button1" android:state_focused="true" android:state_pressed="false"/> <item android:drawable="@drawable/button2" android:state_focused="true" android:state_pressed="true"/> <item android:drawable="@drawable/button3" android:state_focused="false" android:state_pressed="true"/> <item android:drawable="@drawable/button1"/></selector>
<ImageButton android:id="@+id/imageButton5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="61dp" android:layout_y="280dp" android:src="@drawable/drawable_x" />