Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the sizes of every item in a RecyclerView different?

I want to achieve something like this: Google Keep

But here's what I get after trying: My outcome

I already set the height of the layout of the items to WRAP_CONTENT but the result is still the same.

What should I do?

like image 522
Jeffrey Lopez Avatar asked Dec 24 '22 13:12

Jeffrey Lopez


1 Answers

For those who are looking for an answer, just use a StaggeredGridLayoutManager as the RecyclerView's layout manager like this:

recycler.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
like image 50
Jeffrey Lopez Avatar answered Apr 16 '23 15:04

Jeffrey Lopez