我在設計應用程序的佈局時遇到了問題。這就是我試圖讓:Android:使ImageView匹配另一個視圖的高度
=========================================================
| ============= ================ ================ |
| | | | LinearLayout | | LinearLayout | |
| | | | ============ | | ============ | |
| | | | | TextView | | | | TextView | | |
| | ImageView | | ============ | | ============ | |
| | | | ============ | | ============ | |
| | | | | TextView | | | | TextView | | |
| | | | ============ | | ============ | |
| | | | ============ | | ============ | |
| | | | | TextView | | | | TextView | | |
| | | | ============ | | ============ | |
| ============= ================ ================ |
=========================================================
這是whay我這樣做的遠(我已經刪除了的ID爲清楚起見其他東西):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical" >
<ImageView
android:contentDescription="@string/logo"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="left|center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right|center_vertical"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true" />
</LinearLayout>
</LinearLayout>
我問題是我想使用高分辨率圖像並縮小它們以匹配其旁邊的最高線性佈局。我的想法是讓android在低DPI設備上縮小圖像,因此所有平臺都使用相同的圖像和佈局。
現在,主容器高度變得像圖像高度一樣大。我想要的是主容器高度與「最高」線性佈局相同,並強制imageview縮小以適應主容器。
任何想法?
謝謝!
PD:請原諒我的英語! :$
可能的重複[MATCH \ _PARENT如果兄弟視圖較大,WRAP \ _CONTENT如果兄弟視圖較小](http://stackoverflow.com/questions/17119173/match-parent-if-sibling-view-is-更大的包裝內容如果兄弟型視圖更小) – Cris