I found this great thread describing how to "eat the cake and have it too", i.e. use image for a Button
instead of ImageButton
(which doesn't allow SetText()
, resizing, etc.).
This is achieved by using the View attribute:
android:background="@drawable/bgimage"
The only problem with this is that it stretches the image to fit the button size.
Short of hard-coding a fixed button size (in pixels!), is there a way to tell Android not to stretch the background image at all and either crop or pad it?
See Question&Answers more detail:os