【发布时间】:2014-03-03 22:37:13
【问题描述】:
最后一行下方仍有一小块区域是白色的。为什么允许使用以下代码发生这种情况?
<?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>
更新:感谢大家的建议。问题是因为我在适配器的 getView 中膨胀自定义行时做了一些奇怪的事情。我希望我的 ListView 的行大小不同。显然,listview 的总高度是基于计算膨胀的第一行的高度乘以行数得出的。这引起了一个问题,因为我的所有行的大小都不相同。我最终根据添加的每一行的高度动态更改列表视图的高度。
【问题讨论】:
-
请发个截图好吗?顺便说一句,我来自克林顿!小世界。
-
可能是match_parent,我可能会用fill_parent,你试过了吗?
-
天啊,
fill_parent已经被弃用了。这就是他使用match_parent的原因。是的,截图不会是不必要的
标签: android xml listview android-listview