本文介绍了如何使RecyclerView中每个项目的大小不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想实现以下目标:
但是尝试以下是我得到的:
But here's what I get after trying:
我已经将项目布局的高度设置为WRAP_CONTENT,但是结果仍然相同.
I already set the height of the layout of the items to WRAP_CONTENT but the result is still the same.
我该怎么办?
推荐答案
对于正在寻找答案的人,只需使用 StaggeredGridLayoutManager
作为 RecyclerView
的布局经理是这样的:
For those who are looking for an answer, just use a StaggeredGridLayoutManager
as the RecyclerView
's layout manager like this:
recycler.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
这篇关于如何使RecyclerView中每个项目的大小不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!