我想要像 pinterest 这样的 GridView ,为此我实现了 StaggeredGridView图书馆。
因为我遇到了滚动问题。当我向上滚动时,顶部图像移动到下一行,顶部 View 将变为空白。
我在以下带有图片的链接中出现问题。
Stuck with this Issue of StaggeredGridView
注意:
如果我固定了 ImageView 的高度,它可以完美工作,但无法获得我想要的 View 。
我该如何解决这个问题?
您的帮助将不胜感激。
最佳答案
回答这个问题已经很久了,但现在 Recyclerview 支持不同的 layoutmanager 所以要与 recyclerview 交错使用 只需使用下面的代码:-
rcyclerview.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
如果你想将它添加为你的标题,那么在你的标题部分的 bindviewholder 上设置下面的代码:-
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
layoutParams.setFullSpan(true);
关于Android StaggeredGridView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22189288/