Android ListView 自適應大小,不覆蓋下方View
阿新 • • 發佈:2019-02-19
ListView設定為wrap_content,但是隨著ListView中item的增加,ListView將會覆蓋到下方的View,View看不到。
利用android:layout_weight屬性,讓下方View具有更大權重,讓下方的View能正常顯示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/..." >
<ListView
android:id="@+id/dialog_select_listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="100"
...... >
</ListView>
<LinearLayout
android:id="@+id/bottom_btn"
android:layout_width="fill_parent"
android:layout_height="48dip"
android:layout_gravity="center"
android:layout_weight="1"
...... >
......
</LinearLayout>
</LinearLayout>