gpt4 book ai didi

android - 如何在 StaggeredGridView 底部添加 "load more" View

转载 作者:行者123 更新时间:2023-11-29 01:25:57 25 4
gpt4 key购买 nike

我有一个 StaggeredGridLayoutManagerspanCount = 2,方向为 VERTICAL。这是一个无穷无尽的 list 。如何在分页时添加加载更多动画

StaggeredGridLayoutManager 的问题是我无法在行级别提供动态 spanCount。如果是 GridLayoutManager,使用 SpanSizeLookup 很简单。如果您有任何解决方案或建议,请扔掉。谢谢!

Pinterest 已经添加了...但是我不知道是他们自己的习惯还是原生的 enter image description here

最佳答案

好的,经过一些研发,我找到了在 StaggeredGridView 上处理跨度的解决方案。所以它要么是指定的列数,要么是完整的跨度。

需要做的是在 onBindViewHolder() 方法中为每个 View 在适配器中添加以下代码

StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
layoutParams.setFullSpan(true);
holder.itemView.setLayoutParams(layoutParams);

到目前为止,这对我来说是完美的工作解决方案,无需指定任何列跨度数。

关于android - 如何在 StaggeredGridView 底部添加 "load more" View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34065552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com