-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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] Fixed the CarouselView Items overlap issue with PeekAreaInsets #27499
Conversation
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.
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- src/Controls/tests/TestCases.HostApp/Issues/Issue27418.xaml: Language not supported
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/rebase |
46962e8
to
4568d4b
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs
Outdated
Show resolved
Hide resolved
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
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.
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- src/Controls/tests/TestCases.HostApp/Issues/Issue27418.xaml: Language not supported
Comments suppressed due to low confidence (1)
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27418.cs:1
- Ensure that the test case
CarouselItemsShouldRenderProperly
is executed on all relevant platforms, and the issue with Catalyst is properly documented and tracked.
#if TEST_FAILS_ON_CATALYST
src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs
Show resolved
Hide resolved
|
Issue
Loop
is set to true or false.Root Cause of the issue
When VerticalStackLayout is used, the
OnMeasure
method ofMauiCarouselRecyclerView
is called.In this method,
heightMeasureSpec
is 0, whilewidthMeasureSpec
has a value.Since the measurement falls into the "Unspecified" condition, both
widthMeasureSpec
andheightMeasureSpec
are recalculated.During this process, when
viewHolder.ItemView.Measure
is called, SizedItemContentView.OnMeasure is triggered.Inside this method, targetWidth is retrieved from the
GetItemWidth
method in CarouselViewHandler.Android, which subtractsPeekAreaInsets
and ItemSpacing.Due to subsequent calls to OnMeasure in MauiRecyclerView, the MeasuredWidth keeps changing because of incorrect calculations in the "Unspecified" condition.
As a result, the recalculated MeasuredWidth in GetItemWidth becomes too small, causing UI overlap.
Description of Change
WidthMeasureSpec
andHeightMeasureSpec
are 0. If they are, then calculated the new measurements using MeasuredWidth and MeasuredHeight. Otherwise, use the already calculated WidthMeasureSpec and HeightMeasureSpec, ensuring proper measurement calculations.Regressed PR
#25924
Issues Fixed
Fixes #27418
Tested the behaviour in the following platforms
Screenshot
CarouselItemIssue.mov
CarouselViewItemsFix.mov