listview 去除分隔符 android,android-ListView的最后一项之后的分隔符(分隔符)

探讨在Android中,为何在不添加额外视图时ListView在最后一项后未显示分隔符,以及如何通过调整布局结构引入分隔符,以提升布局美感。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当我创建一个仅具有ListView的简单布局时,在最后一项之后没有显示分隔符,这看起来有点难看。

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:id="@android:id/list"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_alignParentTop="true" />

a4cbefe2d32cfd67b6505c21af24fc92.png

但是,我发现如果在列表视图下添加另一个视图并为列表视图设置2724439142703703825920属性,则会在最后一项之后显示分隔符。

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:id="@android:id/list"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_above="@+id/bottom"

android:layout_alignParentTop="true" />

android:id="@+id/bottom"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:background="@android:color/holo_blue_dark"

android:text="Bottom" />

9c6ecd5a1103fa5a85c993b9ef863ab6.png

为什么列表视图的行为是这样的? 如何在仅包含列表视图的布局中的最后一项之后添加分隔符?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值