Here is a picture that will help you understand my problem:
I want to stretch
If your image "111" has no padding itself then simply use android:background"@drawable/111"
Use below code :-
<ImageButton
android:id="@+id/secondActivityBbuttonDownRight"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:scaleType="fitStart"
android:background="@drawable/111" />
android:scaleType="fitXY"
tested and works correctly.
You can also use
android:scaleType="centerCrop"
android:padding="0dp"
Just set this two attributes on the ImageButton
:
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="centerCrop"
With those, you will get the provided src to be stretched, and also if you put some specific width
and height
on that ImageButton
you won't get a rectangle around it.
ImageButton is ImageView.
If you want your image to fill button
than set android:scaleType="fitXY"
, so the image you set in android:src
will be stretched to fill whole image button.
ImageButton has a background under your image and padding.
If you do not want background
set android:background="@android:color/transparent"
.
If you do not want padding
set android:padding="0"
or set background without padding.