Search code examples
androidandroid-layoutandroid-listviewandroid-gridviewandroid-recyclerview

Different Layout Managers in an Activity


I have two different kinds of data that one of them needs to be displayed in a GridLayout (Red) and the other needs to be displayed LinearLayout(Blue).

The whole page scrolls and the data sources may change so the views should update dynamically.

How can I implement this in Android and probably with RecyclerView? enter image description here


Solution

  • One way is to only use the GridLayoutManager with 2 Columns. In case a listitem should wrap both columns set the columnspan for the item to 2 otherwise to 1.