5

I have the following XML:

<ImageButton
    android:id="@+id/SwapTextButton"
    android:layout_width="match_parent"
    android:layout_height="45dp"
    android:layout_weight="0.5"
    android:background="@drawable/my_gradient_button"
    android:scaleType="fitCenter"
    android:src="@drawable/extended_text" />

And it outputs a button which looks like this:

Button text too small

Is there any way to increase the size which the src resource takes up? By that I mean maintain the src within the area of the button, but make it larger than it is now.

I have tried changing the scaleType, but any other setting causes the src resource to display parts of itself outside the button boundary (aka it becomes too large).

I've had a research and there seems to be solutions based in java, but ideally I'd like to keep the solution in xml too.

Can someone suggest a fix/point me in the right direction?

Thanks

Community
  • 1
  • 1
Andy A
  • 236
  • 3
  • 12

2 Answers2

4
<ImageButton
android:id="@+id/SwapTextButton"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_weight="0.5"
android:background="@drawable/my_gradient_button"
android:scaleType="fitXY"
android:src="@drawable/extended_text" />

Try this, fitXY for scaletype should "fill" your ImageButton

Pablo_Cassinerio
  • 887
  • 5
  • 13
0

This worked for me:

android:padding="0dp";
h8pathak
  • 1,342
  • 3
  • 17
  • 29