Skip to content

Commit

Permalink
[Android] Fix bidirectional scrolling on Android (#13623)
Browse files Browse the repository at this point in the history
* [Android] Fix bidirectional scrolling on Android

* Apply suggestions from code review

Co-authored-by: Samantha Houts <samhouts@users.noreply.github.com>

* Update src/Core/src/Platform/Android/MauiScrollView.cs

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>

---------

Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
Co-authored-by: Samantha Houts <samhouts@users.noreply.github.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
  • Loading branch information
4 people committed Mar 8, 2023
1 parent 58a42e5 commit d90d963
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Core/src/Platform/Android/MauiScrollView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,14 @@ protected override void OnLayout(bool changed, int left, int top, int right, int
{
base.OnLayout(changed, left, top, right, bottom);

if (_hScrollView != null && _hScrollView.Parent == this)
if (_hScrollView?.Parent == this && _content is not null)
{
_hScrollView.Layout(0, 0, right - left, bottom - top);
double scrollViewContentHeight = _content.Height;
var hScrollViewHeight = bottom - top;
//if we are scrolling both ways we need to lay out our MauiHorizontalScrollView with more than the available height
//so its parent the NestedScrollView can scroll vertically
var newBottom = _isBidirectional ? Math.Max(hScrollViewHeight, scrollViewContentHeight) : hScrollViewHeight;
_hScrollView.Layout(0, 0, right - left, (int)newBottom);
}

if (CrossPlatformArrange == null)
Expand Down

0 comments on commit d90d963

Please sign in to comment.