-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Ensure an exact measure for the nested horizontal scrollview #13554
Changes from all commits
0ecef32
c91316b
59ee32e
e0a83cc
4290dd3
461fd86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using Android.Animation; | ||
using Android.Content; | ||
using Android.Graphics; | ||
using Android.Hardware.Lights; | ||
using Android.Runtime; | ||
using Android.Util; | ||
using Android.Views; | ||
|
@@ -189,12 +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 = _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.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) | ||
|
@@ -301,6 +310,7 @@ protected MauiHorizontalScrollView(IntPtr javaReference, JniHandleOwnership tran | |
public MauiHorizontalScrollView(Context? context, MauiScrollView parentScrollView) : base(context) | ||
{ | ||
_parentScrollView = parentScrollView; | ||
Tag = "Microsoft.Maui.Android.HorizontalScrollView"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like its for the tests: https://github.com/dotnet/maui/pull/13554/files#diff-e047a3b468635cce7361a6c1bef5be0c7b6a8cce9f8662d737577ea66e34a844R115 (Line 115 in the test below) |
||
} | ||
|
||
public MauiHorizontalScrollView(Context? context, IAttributeSet? attrs) : base(context, attrs) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this happens to me sometimes, is VS is adding this without us noticing ?