How to reflow items in a RecyclerView with the StaggeredGridLayoutManager

前端 未结 3 865
时光说笑
时光说笑 2021-01-14 14:28

I\'m playing around with the StaggeredGridLayoutManager and have something close to what I want. I have a horizontal staggered grid with 2 rows, where some items are the hei

3条回答
  •  臣服心动
    2021-01-14 15:13

    What you want to achieve is completely posible with GridLayoiutManager instead of StaggerdLayoutmanager. Here , I would have use Gridlayoutmanager as follows.

     mGridLayoutManager = new GridLayoutManager(mContext,2,GridLayoutManager.HORIZONTAL,false);
    mGridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
                @Override
                public int getSpanSize(int position) {
                    if(position==0 && position ==1){
                        return 1;
                    }else {
                        return 2;
                    }
                }
            });
    

提交回复
热议问题