Fitting and scaling two images side by side in grid layout

660 Views Asked by At

I have two images--a play button on the left, and a boombox on the right. I am trying to scale the height and widths of these images to look like this

enter image description here

Though my code is producing this:

enter image description here

Essentially, the files are pretty big and not sized correctly, but I don't know why the boombox image is getting cut off. I want the whole boombox to fit, and then the play button to adjust its height according to the height of the boombox.

This is my layout code, though I think I need to make big changes:

<GridLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:stretchMode="columnWidth"
    android:numColumns="2"
    android:scaleType="fitXY"

    >

    <ImageView
        android:id="@+id/play_stop_button"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_column="0"
        android:src="@drawable/play_button_final"
        />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:layout_column="1"
        android:scaleType="fitXY"
        android:src="@drawable/boombox"
        android:id="@+id/boombox"
        />


</GridLayout>
1

There are 1 best solutions below

1
On

Try this,

<GridLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:stretchMode="columnWidth"
    android:numColumns="2"
    android:scaleType="fitXY"

    >

    <ImageView
        android:id="@+id/play_stop_button"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_column="0"
        android:src="@drawable/play_button_final"
        />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_column="1"
        android:scaleType="fitXY"
        android:src="@drawable/boombox"
        android:id="@+id/boombox"
        />


</GridLayout>