How to resize an image inside a button

I am trying to create a button where a text description appears at the bottom and an image at the top. I saw that buttons can do the trick with android: drawableTop attribute, but I cannot resize the image

Methods like adjustViewBounds, android: scaleType = "fitCenter", fitXY don't work.

Here is my xml code for the button

<Button
            android:text="Start Running"
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:id="@+id/run"
            android:onClick = "RUN"
            android:scaleType="fitCenter"
            android:drawableTop="@drawable/runner"
            android:layout_marginBottom="3sp"
            android:layout_marginLeft="2sp"
            android:layout_marginRight="3sp"
            android:layout_marginTop="0sp"
            />

      

Please suggest something?

+3


source to share


1 answer


Create a horizontal LinearLayout with two views - Look with your image as background and TextView with appropriate text. After that, set an OnClickListener for this LinearLayout and treat it like a normal button.



+1


source







All Articles