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
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.
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.
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
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With