Search code examples
androidandroid-recyclerviewgridlayoutmanager

row and column spans in recycler gridlayout manager


I have this layout that I want to create with the same column and row spans for each grid item and my activity has a RecyclerView with a GridLayoutManager.

Can you please give me advice on fixing the column and row span for each item in the adapter?

Here's the layout:

image link

Regards.


Solution

  • Apparently you have a mix of items that span both rows and columns. My understanding about GridLayoutManager is that you can span columns for vertical orientation and rows for horizontal orientation, but not both at the same time.

    I would recommend that you look at GridLayout instead. GridLayout allows you to span both rows and columns. It just doesn't use an adapter the way RecyclerView does.

    You may also be able to find some custom RecyclerView layout managers on GitHub that allow spans in both directions.