在main.xml中的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/settingsLayoutId"
android:gravity="center">
<!--这个android:background就读取自己定义的XML文件 -->
<ImageButton
android:id="@+id/email"
android:layout_width="84px"
android:layout_height="112px"
android:layout_x="140px"
android:layout_marginLeft="20px"
android:background="@drawable/emailimage"
android:scaleType="centerInside"
/>
</LinearLayout>
然后在drawable-mdpi中建立 emailimage.xml 文件
<?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/emailonmouseup"
/>
<item
android:drawable="@drawable/email"
/>
</selector>
还有就是email.png和emailonmouseup.png图片
ok,只要在界面显示出来,就有单击改变imagebutton图片的效果了·······