Tinashe
Tinashe

Reputation: 3215

Recyclerview grid layout manager that fills one column first

I would like a recyclerview layout manager that works like a GridlayoutManager with two columns but fills the first column first before it adds items to the 2nd column. Or rather adds the remaining items to the second column. Any suggestions?

Upvotes: 5

Views: 2479

Answers (1)

Budius
Budius

Reputation: 39836

There's no direct layout manager that will do that for you BUT, I guess it's better, easier, more rational to re-order the List or whatever data structure is filling the adapter than trying to mess with the layout manager.

An example of how to do that would be during bindView:

public void onBindViewHolder (VH holder, int position) {
    position = translatePosition(position);
    // then carry on with your normal bind code
}

then create this method translatePosition with some simple math that will re-order stuff the way you want/need.

Upvotes: 1

Related Questions