android - How to Preserve aspect ratio of a button's background image with xml -


i have set of buttons (not imagebuttons) declared in xml. contain background image. want able dictate width of button via xml, via use of weight... want let height dictated aspect ratio of image.

i saw similar question here, answer involved addition of android:adjustviewbounds="true" question concerned imageviews rather buttons , when tried same additions button code, didn't appear work.

can want achieved?

you can use:

android:scaletype="fitxy"  

in layout of button or imagebutton (it's better if use imagebutton).


Comments