工作:安卓的ListView layout_height爲wrap_content它只是包裹在ListView第一項:WRAP_CONTENT不會在列表視圖
...
<ListView android:id="@+id/points_add_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/points_add_progress"/>
<ImageView android:id="@+id/points_add_progress2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="@id/points_add_list"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:src="@android:color/darker_gray"/>
</RelativeLayout>
</ScrollView>
如果我使用例如300dp而不是wrap_content,其他一些項目是可見的。
我的列表視圖適配器自定義視圖佈局XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView android:id="@+id/points_add_row_title"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="@style/PlaneText"/>
<RadioButton android:id="@+id/points_add_row_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
[ListView的高度填充整個屏幕,儘管設置爲wrap \ _content]可能的重複(http://stackoverflow.com/questions/15479915/height-of-listview-fills-the-whole-screen-although -set-as-wrap-content) – CommonsWare
我發現如果我刪除ScrollView,列表視圖顯示所有項目。爲什麼? – user2136334