[英]ListView row height with ImageView
我有一個自定義行的Listview,其中包含:
Button TextView ImageView ImageView Button
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp"
android:paddingTop="20dp" >
<Button
android:id="@+id/bonus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@drawable/green_button"
android:layout_marginLeft="2dp"
android:text="Test" />
<TextView
android:id="@+id/name"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/bonus"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/images_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/missed"
android:background="#ffff0000"
android:layout_toRightOf="@+id/name"
android:orientation="horizontal" >
<ImageView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:src="@drawable/live"
/>
</LinearLayout>
<Button
android:id="@+id/missed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:background="@drawable/red_button"
android:layout_marginRight="2dp"
android:text="test2" />
</RelativeLayout>
所以這里在一個小屏幕上,例如(Wildfire)兩個按鈕和文本看起來不錯,但我的圖像大小為72x72將拉伸行高,我將有一個非常高,它看起來不漂亮..
如何自動調整圖像大小以適應行並與按鈕大小相同?
謝謝! (如果不清楚,我可以附上圖片)
要使ImageView與按鈕的高度相同,請使其與按鈕的頂部和底部對齊。 這將保證高度匹配。
<LinearLayout
android:id"@+id/images_layout"
android:layout_alignTop="@id/bonus"
android:layout_alignBottom="@id/bonus"
android:orientation="horizontal"
android:layout_toRightOf="@id/name" >
...
</LinearLayout>
希望這可以幫助。
嘗試這個:
<LinearLayout
android:id="@+id/images_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/missed"
android:background="#ffff0000"
android:layout_toRightOf="@+id/name"
android:orientation="horizontal" >
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/live"
/>
</LinearLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.