Skip to content

Commit

Permalink
clean up and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hartez committed Mar 8, 2023
1 parent 0ecef32 commit c91316b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Core/src/Platform/Android/MauiScrollView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,20 @@ protected override void OnLayout(bool changed, int left, int top, int right, int

if (_hScrollView?.Parent == this && _content is not null)
{
double scrollViewContentHeight = _content.Height;
var scrollViewContentHeight = (int)_content.Height;
var hScrollViewHeight = bottom - top;
var hScrollViewWidth = right - left;

//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.Measure(MeasureSpec.MakeMeasureSpec(right - left, MeasureSpecMode.Exactly), MeasureSpec.MakeMeasureSpec(newBottom, MeasureSpecMode.Exactly));
_hScrollView.Layout(0, 0, right - left, (int)newBottom);
hScrollViewHeight = _isBidirectional ? Math.Max(hScrollViewHeight, scrollViewContentHeight) : hScrollViewHeight;

// Ensure that the horizontal scrollview has been measured at the actual target size
// so that it updates its internal bookkeeping to use the full size
_hScrollView.Measure(MeasureSpec.MakeMeasureSpec(right - left, MeasureSpecMode.Exactly),
MeasureSpec.MakeMeasureSpec(hScrollViewHeight, MeasureSpecMode.Exactly));

_hScrollView.Layout(0, 0, hScrollViewWidth, hScrollViewHeight);
}

if (CrossPlatformArrange == null)
Expand Down

0 comments on commit c91316b

Please sign in to comment.