1
我想把ImageB
上ImageA
。我應該如何實現這一目標?如何使用RelativeLayout讓圖像與另一圖像的高度相匹配?
注:
- 我不想解決我的身高兩個圖像,這樣我可以保持自己的縱橫比。
爲
ImageA
和ImageB
高度是不同的。
任何幫助將不勝感激。
我想把ImageB
上ImageA
。我應該如何實現這一目標?如何使用RelativeLayout讓圖像與另一圖像的高度相匹配?
注:
爲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 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範靈請嘗試這種方式。 –