0

I am using RecyclerView to display data using GridLayoutManager , but I could only generate it with fixed columns. How do I dynamically display something like this image enter image description here

Santanu Sur
  • 10,997
  • 7
  • 33
  • 52
Aweda
  • 323
  • 1
  • 4
  • 15
  • You can use StaggeredGridLayoutManager – Swayangjit Oct 23 '19 at 09:12
  • You can create recyclerView with multiple custom cellViews, I guess in your case you will have two different cells. Or, take a look at this: https://stackoverflow.com/questions/36514887/layoutmanager-for-recyclerview-grid-with-different-cell-width – Walid Oct 23 '19 at 09:12
  • Swayangjit & Walid your suggestions helped, thanks a bunch. – Aweda Oct 24 '19 at 11:50

1 Answers1

2

Use StaggeredGridLayoutManager

Try like this

yourRecylerView.setLayoutManager(new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));

For details see this article.

Jakir Hossain
  • 3,830
  • 1
  • 15
  • 29