2015-10-02 35 views
1

我想把ImageBImageA。我應該如何實現這一目標?如何使用RelativeLayout讓圖像與另一圖像的高度相匹配?

enter image description here

注:

  • 我不想解決我的身高兩個圖像,這樣我可以保持自己的縱橫比。
  • ImageAImageB高度是不同的。

    ​​

任何幫助將不勝感激。

+0

可以使用Android:alignTop = 「@ ID/imageA」 和alignBottom = 「@ ID/imageA」 –

+0

我同意@Phan範靈請嘗試這種方式。 –

回答

0

試試這個代碼

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

希望這有助於

相關問題