I wanted to put ImageB
on top of ImageA
. How should I achieve that?
Note:
The height for ImageA
and ImageB
are different.
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ImageView
android:id="@+id/imageA"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scaleType="fitCenter"
android:src="@drawable/imageA"
android:adjustViewBounds="true"/>
<!-- How to let imageB matches imageA's height ? -->
<ImageView
android:id="@+id/imageB"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/imageB"/>
</RelativeLayout>
Any help will be appreciated.
Try this code
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<ImageView
android:id="@+id/imageA"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scaleType="fitCenter"
android:src="@drawable/imageA"
android:adjustViewBounds="true"/>
<!-- How to match let imageB matches imageA's height ? -->
<ImageView
android:id="@+id/imageB"
android:layout_alignTop="@id/imageA" // add it
android:layout_alignBottom="@id/imageA" // add it
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_alignParentTop="true" // remove it
android:layout_alignParentRight="true"
android:src="@drawable/imageB"/>
</RelativeLayout>
Hope this help