Two dimensional ScrollView for MonoDroid

There is no two dimensional scroll view for Android out of the box – the one that lets user scroll in both horizonal and vertical direction. There are either horizontal (HorizontalScrollView) or vertical (ScrollView) but not both. After some Googling around I’ve found that devs were mosty experimenting with combining HorizontalScrollView within ScrollView. This approach didn’t work for me and even if it did it has some drawbacks (such as scrolling is rectriected by one of the two directions at the same time).

At this point I was considering creating my own proper ScrollView from scratch but luckily I’ve stumbled across an implementation of the same idea by Matt Clark. The only problem was that I am on Mono For Android and Matt’s implementation is in pure java. Plus I didn’t have a clue whether his solution actually worked. Nevertheless I did convert his java code to C#/Mono For Android and voila, it worked almost immediately (after an hour or so of manual conversion – damn those java’s getters and setters instead of properties).

Attached are the C# sources in case anybody else needs it.

TwoDScrollView.cs (50.08 kb)

Leave a Reply