Anupriya
Anupriya

Reputation: 1693

How to count number of rows, when FlexBoxLayoutManger set as layoutManager for RecyclerView

I am using FlexboxLayoutManager as:

FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(this);
recyclerView.setLayoutManager(flexboxLayoutManager);

Now I have to inflate items in recyclerView and if number of items taking more than 2 rows, then I have to show "Show More" option as last item in second row itself. How can I achieve this?

Each row contains different number of items, i.e. columns may vary as per items length, thats why using FlexBoxLayoutManager.

Upvotes: 5

Views: 2001

Answers (1)

Công Hải
Công Hải

Reputation: 5241

try it

        flexBoxLayoutManager.flexLines.size

Upvotes: 3

Related Questions