AlirezaEs
AlirezaEs

Reputation: 31

How to implement horizontal grid recycler view by horizontal span

How to implement horizontal grid recycler view by horizontal span like this:

What i want

I use StaggeredGridLayoutManager and GridLayoutManager but the result is:

Result

Upvotes: 3

Views: 1895

Answers (2)

Georgeous
Georgeous

Reputation: 1

Use

GridLayoutManager(context, NUMBER_OF_COLUMNS, RecyclerView.VERTICAL, false)

If you want to keep specific number or rows calculate the number of columns dynamically

Upvotes: 0

Mittal Patel
Mittal Patel

Reputation: 6089

You can use StaggeredGridLayoutManager with the span value 3 and horizontal orientation as below

StaggeredGridLayoutManager mLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(mLayoutManager);

Upvotes: 1

Related Questions