Shai
Shai

Reputation: 25595

Making two adjacent ImageViews Drawables have the same height

I currently have two image views:

    <ImageView
        android:id="@+id/IV1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="30dp"
        android:adjustViewBounds="true"
        android:background="#ff0000"
       />

    <ImageView
        android:id="@+id/IV2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/IV1"
        android:layout_centerVertical="true"
        android:src="@drawable/shadow_pages"
        android:adjustViewBounds="true"
        android:background="#00ff00"
        />

These two ImageViews are being loaded with two different images, which have different dimensions.

Problem is: the images get scaled (which is okay) to fit the view, but the height of the drawables are not the same (because they originally have different dimensions), so the height of the drawable on IV2 is larger than the height of the drawable on IV1 - which then gives the impression that the 2nd image is "taller" than the 1st one.

How can I set the height of the drawable on IV2 so it will be the same height as the drawable on IV1?

EDIT: I'd prefer avoiding setting specific height values

Upvotes: 0

Views: 289

Answers (1)

Ram kiran Pachigolla
Ram kiran Pachigolla

Reputation: 21201

Keep the imageviews in a lineaLayout or RelativeLayout and set height as

android:layout_height="fill_parent"

or

fix the height of both imageViews as android:layout_height="200dp"//==> This will be your wish

Upvotes: 2

Related Questions