RecyclerView with GridLayoutManager: Scrolling Both Directions
I have a RecyclerView that uses a GridLayoutManager. The number of rows/columns will vary in different scenarios, all the elements that will be displayed are the same size, and I need to be able to scroll both vertically and horizontally. I have tried the following:
this.rvPuzzle.SetLayoutManager(new SquareLayoutManager(this, this.Puzzle.ColumnCount, GridLayoutManager.Vertical, false));
this.rvPuzzle.SetAdapter(new SquareAdapter(this.Puzzle.FlatSquares));
This makes the elements the correct height & vertically scrollable, but causes the elements to be horizontally cropped to fit them all on the screen (and therefore obviously not horizontally scrollable, since all columns are now visible). I tried creating a custom Layout Manager by inheriting from GridLayoutManager
and overriding CanScrollHorizontally()
& CanScrollVertically()
as follows:
public override bool CanScrollHorizontally() { return true; }
public override bool CanScrollVertically() { return true; }
However, this did not make any difference. Is there any way to enable scrolling in both directions without an extra HorizontalScrollView and/or ScrollView?