11

I want to resize my ImageButton using mouse on graphic layout or using code by android:layout_width , android:layout_height. But whenever I do this, the ImageButton isn't resized, in fact and it's not smaller but it is cut at the edges.

thanks in advance

Tomik
  • 23,597
  • 7
  • 120
  • 99
eng.ahmed
  • 865
  • 4
  • 16
  • 36

4 Answers4

21

First try to use android:background instead of android:src for setting the image on the button.In most cases,it helps.If not,then see these..

Community
  • 1
  • 1
ridoy
  • 6,158
  • 2
  • 27
  • 60
4
    <ImageButton
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:background="@drawable/ic_star_border"
    />
or
       <ImageButton
            android:layout_width="36dp"
            android:layout_height="36dp"
            android:background="?selectableItemBackgroundBorderless"
            android:scaleType="fitXY"
            android:src="@drawable/ic_delete" />
live-love
  • 41,600
  • 19
  • 198
  • 177
2

You will have to specify fixed dimensions for the buttons (use dp instead of px). Example:

<ImageButton 
  android:background="@drawable/ic_menu_more" 
  android:layout_width="50dip" 
  android:layout_height="50dip" 
/>
Kemat Rochi
  • 893
  • 3
  • 18
  • 35
jlopez
  • 6,287
  • 2
  • 51
  • 90
1

It might be the problem with size of your image..Try to use resized image then use it in your image button.Then you can set the width and height of the button .

Payal
  • 913
  • 1
  • 9
  • 27