I'm trying to implement a facebook like, gallery grid, where items have different sizes:
I was trying to use different libraries/solutions but for now without success:
I tried to use AsymemetricGridView. But the problem with this implementation is that there are empty dead spaces left in the grid after going throw the adapter.
I also thought of using the
StaggeredGridLayoutManager
and aRecycleView
, but items, in this case, don't have equal or half sizes to other items as it implemented in the Facebook gallery.
Now I thinking of providing different view holders for different cases in the adapter, but I really don't like this idea. What is a better approach to this task?
You can use recyclerview with StaggeredGridLayoutManager to accomplish this. StaggeredGridLAyoutManager already handles this, also u can use setFullSpan for a image to use a whole row
Finally, I have decided to use the TwoWayView library.
That you can get from: https://github.com/lucasr/twoway-view
In my code I did the following major changes:
Added TwoWayView in the xml layout:
In code I made the following changes:
Here is the end result: