Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force ImageButton To Scale Like ImageView

Tags:

android

I have an ImageView that scales down when I set the layout width to fill parent. But when I change it to an ImageButton, it doesn't scale. How do I get the ImageButton to look like the ImageView?

Example

like image 571
Ben Avatar asked Nov 20 '25 17:11

Ben


1 Answers

Use the android:scaleType attribute (set to center inside or something like that).
However, even if you can get it to scale, I am not sure if you'll get the result you want. The imagebutton displays a regular button, but with an image instead of text, that is you'll get the button-borders around your image. If the imageview works as you want it to, why don't you keep it as an imageview, but set the focusable and clickable attributes on it?

like image 62
Jave Avatar answered Nov 22 '25 08:11

Jave



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!