Different (dynamic) items height in GridLayoutManager

前端 未结 2 1467
不知归路
不知归路 2020-12-16 13:50

I have a RecyclerView and GridLayoutManager with 2 columns. How can I force LayoutManager to be according with template on the first screenshot? Now I have result as on the

2条回答
  •  粉色の甜心
    2020-12-16 14:23

    GridLayoutManager will use a grid, and you can set some span, but not different heights for different cells.

    What you want is a StaggeredGridLayoutManager. This will just put the items on the screen if they fit, leading to your needed result. You can also change the reordering behavior, if you want to, by using setGapStrategy.

提交回复
热议问题