在 ListView 中使用 clipToPadding 时,项目会过早回收 [英] When using clipToPadding in ListView's the items get recycled prematurely

查看:24
本文介绍了在 ListView 中使用 clipToPadding 时,项目会过早回收的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置时

android:clipToPadding="false"

在 2.3.3 android 设备上的标准 ListView 中,我看到列表项被过早回收.适配器的视图在完全滚动超过填充时被删除,而不是滚动超过屏幕边缘导致视图被过早删除.有没有人能够解决这个问题?

in a standard ListView on a 2.3.3 android device I am seeing that the list items are being recycled prematurely. The adapter's view is being removed when it is fully scrolled past the padding versus being scrolled past the edge of the screen resulting in views being removed too early. Has anyone been able to solve this issue?

推荐答案

Clip to padding 是默认行为.在视图不可见时(即通过填充)立即回收视图是正常和预期的行为.

Clip to padding is the default behavior. Having the view recycled as soon as it's not visible (i.e. past the padding) is the normal and expected behavior.

您确定您没有尝试将 clipToPadding 设置为 false 吗?在这种情况下,ListView 仍然会在进入填充区域后立即回收其子项.属性 clipToPadding 只影响绘图,不会被 ListView 等布局算法考虑在内.我们可以在平台的未来版本中修复此行为,但现在对您没有帮助,抱歉:(

Are you sure you're not trying to set clipToPadding to false? In that case, ListView will still recycle its children as soon as they enter the padding area. The attribute clipToPadding only affects drawing and is not taken into account by layout algorithms such as ListView's. We could fix this behavior in a future version of the platform but that won't help you right now, sorry :(

这篇关于在 ListView 中使用 clipToPadding 时,项目会过早回收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆