android给listview的item设定高度

在item的layout文件中,用android:layout_height设置item的高度。
运行,高度设置无效。

解决办法:

给item设定minHeight,即可.

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minHeight="?android:attr/listPreferredItemHeight" >

<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:text="@string/hello" />
</LinearLayout>