Android 如何让一个图像与另一个图像匹配';用相对长度表示高度?
我想把Android 如何让一个图像与另一个图像匹配';用相对长度表示高度?,android,android-layout,android-relativelayout,Android,Android Layout,Android Relativelayout,我想把ImageB放在ImageA之上。我应该如何做到这一点 注: 我不想固定这两幅图像的高度,以便保持它们的纵横比 图像A和图像B的高度不同 任何帮助都将不胜感激 试试这段代码 <RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent"> <ImageView android:id="@+id/imageA"
ImageB
放在ImageA
之上。我应该如何做到这一点
注:
- 我不想固定这两幅图像的高度,以便保持它们的纵横比
和图像A
的高度不同图像B
<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>
希望有此帮助请尝试此代码
<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>
希望这个帮助你可以使用android:alignTop=“@id/imageA”和alignBottom=“@id/imageA”我同意@Phan Văn Linh ans试试这个方法。你可以使用android:alignTop=“@id/imageA”和alignBottom=“@id/imageA”我同意@Phan Văn Linh ans试试这个方法。