androidbuttonimageviewscaletypeadjustviewbounds

ImageView adjustViewBounds not working with fitXY


I use the following code to show my button

(Because I need to add the text on the button, so I will not use the ImageButton)

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/bottom001"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"/>
</RelativeLayout>

But the ImageView will have some empty area in the View

I think "fitXY" will fill the View, but it didn't

bottom

How can I do in this case?

Thanks for your help :)


Solution

  • set android:layout_width="wrap_content" And Use LinearLayout

    Finally

    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/test"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"/>
    

    For details please read android-imageview-scaletype-samples

    FIT_XY

    Scale the image using FILL.Stretch the picture inside the available width and height, disgarding the aspect ratio.