1.在ListView的布局文件中把属性android:layout_height设置成"wrap_content"<ListView android:cacheColorHint="#00000000" android:textColor="#ff435346" android:textSize = "20sp" android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout="@+id/textViewCurrentBase" android:listSelector="#00000000" android:drawSelectorOnTop="false"/> 2.设置子项xml文件(比如这里把一个item.xml设置成ListView的一行)的各个控件android:layout_height的值。这里80sp+40sp就是你需要的一行的高度了。 item.xml如下: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas./apk/res/android" android:id="@+id/TextView01" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:focusable="false" android:textColor="@drawable/white" android:id="@+id/ItemTitle" android:layout_height="80sp" android:layout_width="fill_parent" /> <TextView android:focusable="false" android:id="@+id/ItemText" android:textColor="@drawable/blue" android:layout_height="40sp" android:layout_width="wrap_content" android:layout_below="@+id/ItemTitle" /> <Button android:id="@+id/ItemButton" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentRight="true" /> </RelativeLayout> 希望有用。 |
|