2012-09-11 22 views
3

我有個親戚的佈局,包括一個TextView和ImageView的:機器人的ImageView縮放以適應另一個View

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true"/> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:adjustViewBounds="true"/> 
</RelativeLayout> 

它看起來如下:

enter image description here

我想達到什麼是:

enter image description here

這意味着我想讓我的ImageView按比例縮放以適應TextView的高度。它可以在沒有java編碼的xml中完成嗎? 如果我能寫的東西像

android:layout_height="match_that_TextView" 

能解決這個問題,但是這是不可能的,我猜。

回答

1

在RelativeLayout中確定高度

+0

我不想使用幻數。我希望ImageView的高度取決於TextView的高度。 – Nick

+0

然後只能以編程方式獲取大小項目TextView並設置高度ImageView。 –