How can I implement layout like this with recyclerview?

I use GridlayoutManager and override getSpanSize method. I was able to implement three and one column in the same recyclerview. But I was not able to implement five columns in the same recyclerview.

>Solution :

If you know which row will have five column and which has three column so you can use below code

GridLayoutManager layoutManager = new GridLayoutManager(this, 3);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
    public int getSpanSize(int position) {
        if (position > 3)
            return 5;
            return 3;

Leave a Reply