Ogen
Ogen

Reputation: 6709

Having trouble stretching image in ImageButton

Here is my code for the ImageButton

<ImageButton
            android:id="@+id/undoButton"
            android:clickable="true"
            android:scaleType="fitXY"
            android:src="@drawable/undobutton_disabled"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/chessBoard" />

Here is the result so far

enter image description here This is what Ive tried so far:

1. Made the scaleType fitCenter, but that didn't work.

2. Made the imagebutton height and width the same size as my picture, but that didnt work either.

Any help is appreciated, thanks.

Upvotes: 1

Views: 44

Answers (2)

Szymon
Szymon

Reputation: 43023

If you're wrapping your content, your ImageView will fit the actual size of your image.

You need to replace

android:layout_width="wrap_content"
android:layout_height="wrap_content"

with something else, e.g.

android:layout_width="match_parent"
android:layout_height="match_parent"   

Upvotes: 1

Ogen
Ogen

Reputation: 6709

Ok I'm sorry, I JUST figured out the answer as soon as i posted this question.

android:padding="0dp"

That fixed my problem.

EDIT: Should I just delete this question?

Upvotes: 1

Related Questions