android提供了android.widget.ImageButton控件,在使用该控件时,有以下两点注意事项:
1、该控件默认带有背景,因此如果不需要背景,需要手动将背景设为null
2、如果只是将背景设为null,该控件的padding(比较大)依然存在,因此,必须手动设置padding或者设一张新的背景图。
关于背景图与padding的问题,其实帮助文档有说明:
Set the background to a given Drawable, or remove the background. If the background has padding, this View's padding is set to the background's padding. However, when a background is removed, this View's padding isn't touched. If setting the padding is desired, please use
setPadding(int, int, int, int)
.