RecyclerView GridLayoutManager with full width header

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:
                    default:
                        return 1;
                }
            }
        });

And check these links:

  • RecyclerView: Grid with header
  • Set span for items in GridLayoutManager using SpanSizeLookup

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)