最後一行下方仍有一小塊區域爲白色。爲什麼允許下面的代碼發生?在Android中的ListView下方更改空白的顏色
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/lightGray">
<ListView
android:id="@+id/home_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white" >
</ListView>
</LinearLayout>
UPDATE:感謝大家的建議。這個問題是因爲我在適配器的getView中膨脹自定義行時所做的奇怪事情。我想我的ListView的行是不同的大小。顯然,列表視圖是通過計算第一行膨脹的高度乘以行數得到其總高度。這導致了一個問題,因爲我所有的行不是相同的大小。我最終根據每行添加的高度動態更改列表視圖的高度。
請問您張貼截圖嗎?在旁註中,我來自克林頓!小世界。 – adneal
也許這是match_parent,我可能會用fill_parent,你試過嗎? – Tomas
Omg,'fill_parent'已經被棄用了,這就是爲什麼他使用'match_parent'。是的屏幕截圖不會是不必要的 –