如何使用RelativeLayout让图像与另一个图像的高度匹配?

时间:2015-10-02 10:18:31

标签: android android-layout android-relativelayout

我想将 ImageB 置于 ImageA 之上。我该怎么做?

enter image description here

注意:

  • 我不想为两个图像修正我的高度,以便我可以保持它们的宽高比。
  • ImageA ImageB 的高度不同。

    <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>
    

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

试试此代码

?

希望这个帮助