1

我的LinearLayout包含2個TextView(TextView1和TextView2)和一個ImageView。現在我希望LinearLayout始終具有固定的高度,即ThextView1的高度,以便ImageView使用fill_parent將其圖像的大小調整爲TextView1的高度。將ImageView調整爲TextView的高度

_____________________________________ 
|TextView1------------------ ImageView| 
|TextView1 --- TextView2 --- ImageView| 
|TextView1 ----------------- ImageView| 

的硬類解釋...的ImageView的始終應該有TextView1的高度並調整自己的形象(同時保持原來的縱橫比)。

這可能只是用layout-xml來做,還是我需要以編程的方式來做?

我希望你能幫助我:)

回答

1
<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     ... /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     ... /> 

</LinearLayout> 

我沒有測試過這一點。這是你指的是什麼?

相關問題