0

I'am developing an android app, and I have some several image buttons. My question is: My image button have a size 25dp x 25dp, and the image that I'am using have 75px x 75px, and it becomes like this enter image description here

and the real image is enter image description here

Any idea about what is happening ? Is necessary the image have 25px x 25px too ? What is the best way to make it work ?

Thanks in advance

Gonçalo Ribeiro
  • 115
  • 2
  • 11
  • Google is your friend: http://stackoverflow.com/questions/15116393/fit-image-in-imagebutton-in-android – Nantoka Jun 22 '14 at 13:12

2 Answers2

1

Add android:scaleType="fitCenter" or android:scaleType="fitXY" in your ImageButton tag in Xml

Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
1

There are a few different ways for you to solve this. Have a look at android:scaleType here. android:scaleType="fitCenter" and android:scaleType="fitXY" will both work for you.

You can have a look at some samples and how each of them affect the image here

Peter
  • 549
  • 7
  • 20