RecyclerView GridLayoutManager with full width header

天大地大妈咪最大 提交于 2019-12-02 19:00:55
Alex

Try with this:

mLayoutManager = new GridLayoutManager(this, 2);
        mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                switch(mAdapter.getItemViewType(position)){
                    case MyAdapter.HEADER:
                        return 2;

                    case MyAdapter.ITEM:
                        return 1;

                    default:
                        return 1;
                }
            }
        });

And check these links:

http://blog.sqisland.com/2014/12/recyclerview-grid-with-header.html Set span for items in GridLayoutManager using SpanSizeLookup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!