How to make a bi-directional RecyclerView?

1.4k views Asked by At

I need to be able to make a bi-directional RecyclerView. Basically, it would scroll vertically, but each row would be a horizontal list of tiles that could scroll. The initial scroll position would be at the top and left. The user could scroll down, and scroll to the right with each row.

Any ideas on how to do this? (e.g. with a custom LayoutManager or touch event interception).

1

There are 1 answers

2
afollestad On BEST ANSWER

I was able to solve the issue using a custom view implementation.

At the root, I have a custom ScrollView; when onMeasure is called, the ScrollView tells its children how tall they should. In this case, they are half the height of the ScrollView. The width matches the height so they display as square tiles.

Each of the ScrollView children are RecyclerView's with a horizontal LinearLayoutManager. Since the ScrollView tells each child how tall to be, there's no issues with measurement and they actually scroll very well in both directions (vertically and horizontally).

sample of solution