Currently I am using GridLayoutManager
for my RecyclerView
. The span is 2 and orientation is horizontal like below
var myRecyclerView RecyclerView?
myRecyclerView?.layoutManager = GridLayoutManager(context, 2, LinearLayoutManager.HORIZONTAL, false)
var myAdapter MyAdapter?
myAdapter?.items = myItemList
myRecyclerView?.adapter = myAdapter
In this case the way data gets laid out as below
0, 3
1, 4
2, 5
However, the requirement is that the date should be ordered as below
0, 1
2, 3
4, 5
I looked at GridLayoutManager
or Adapter
to manipulate the order but couldn't find one. Also, I can't sort on specific attribute of items to achieve this order.
Any suggestions would be deeply appreciated.
Thanks!
To Add to @Awm4n's anser above, I needed to add correct span count (2 in this case) and orientation as
LayoutManager.VERTICAL
. That did the trick.