Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix bidirectional scrolling on Android #13623

Merged
merged 3 commits into from
Mar 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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