问题描述
我想知道 StaggeredGridLayoutManager 的 onBindViewHolder()方法内部的视图跨度索引(以管理视图之间的填充)。
问题在于 getSpanIndex()始终返回-1:
int spanIndex = ((StaggeredGridLayoutManager.LayoutParams) ((CardItemHolder) holder).getCardView().getLayoutParams()).getSpanIndex(); // always returns -1
我认为这是因为目前尚不知道span索引。
我发现对于 GridLayoutmanger ,我可以像这样获得跨度索引:
int spanIndex = layoutManager.getSpanSizeLookup().getSpanIndex(position,layoutManager.getSpanCount());
但是, StaggeredGridLayoutManager 类没有任何 getSpanSizeLookup()方法。
有什么想法可以在 StaggeredGridLayoutManager 的 onBindViewHolder()方法内获取视图的跨度索引吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)