Islomjon Meliboyev
Islomjon Meliboyev

Reputation: 23

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.

Upvotes: 2

Views: 84

Answers (1)

Jaydeep parmar
Jaydeep parmar

Reputation: 569

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() {
    @Override
    public int getSpanSize(int position) {
        if (position > 3)
            return 5;
        else
            return 3;
    }
});

Upvotes: 1

Related Questions