Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i resize imageButton?

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

like image 533
eng.ahmed Avatar asked Feb 11 '13 05:02

eng.ahmed


People also ask

How do you scale ImageButton?

How to programatically resize and show them? Use a android:scaleType="fitCenter" to have Android scale the images, and android:adjustViewBounds="true" to have them adjust their bounds due to scaling. All of these attributes can be set in code on each ImageButton at runtime.

What is android ImageButton?

Displays a button with an image (instead of text) that can be pressed or clicked by the user. By default, an ImageButton looks like a regular Button , with the standard button background that changes color during different button states.


2 Answers

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..

  • ImageButton in Android
  • Resize ImageButton?
like image 102
ridoy Avatar answered Oct 26 '22 06:10

ridoy


    <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" />
like image 45
live-love Avatar answered Oct 26 '22 07:10

live-love