Skip to content Skip to sidebar Skip to footer

Android - Scaling Of Button With Background Image

I have a screen layout that includes 3 Button controls contained within a linear layout (horizontal). The Buttons each have a background image. See XML below :

Solution 1:

The buttons get stretched horizontally because the LinearLayout is set to fill parent, and each button have weights that make them stretch. The heights are set to wrap_content, and there isn't any content. The image is set as a background, which won't have any effect on how big the button is.

It's probably best you change the Buttons to ImageButtons and use android:src instead of android:background. For example :

<ImageButton
    android:id="@+id/notificationform_btn_Approve"
    android:layout_width="0dp"
    android:layout_weight="1"
    android:layout_height="wrap_content"
    android:src="@drawable/btn_approve"
    android:onClick="btnApprove_Click" />

Post a Comment for "Android - Scaling Of Button With Background Image"