- 设置ImageButton的图片可通过android:src属性,也可以通过setImageResource(int)方法来实现。
- ImageButton所显示的图片若不能完全覆盖掉背景色时,使用ImageButton一般要将背景色设置为其他图片或直接设置为透明。
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:andro />
</TableRow>
</TableLayout>
其中ImageButton的 android:src在drawable-mdpi中新建myselector.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:andro />
</selector>
当按下ImageButton后,显示如下: