[Android] Fixed the CarouselView Items overlap issue with PeekAreaInsets - #27499
Merged
Merged
Conversation
Ahamed-Ali
marked this pull request as ready for review
January 31, 2025 14:33
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Member
|
/rebase |
github-actions
Bot
force-pushed
the
fix-27418
branch
from
February 3, 2025 11:39
46962e8 to
4568d4b
Compare
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
jsuarezruiz
reviewed
Feb 4, 2025
rmarinho
reviewed
Feb 4, 2025
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
There was a problem hiding this comment.
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
CarouselItemsShouldRenderProperlyis executed on all relevant platforms, and the issue with Catalyst is properly documented and tracked.
#if TEST_FAILS_ON_CATALYST
rmarinho
approved these changes
Feb 6, 2025
Member
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Loopis set to true or false.Root Cause of the issue
When VerticalStackLayout is used, the
OnMeasuremethod ofMauiCarouselRecyclerViewis called.In this method,
heightMeasureSpecis 0, whilewidthMeasureSpechas a value.Since the measurement falls into the "Unspecified" condition, both
widthMeasureSpecandheightMeasureSpecare recalculated.During this process, when
viewHolder.ItemView.Measureis called, SizedItemContentView.OnMeasure is triggered.Inside this method, targetWidth is retrieved from the
GetItemWidthmethod in CarouselViewHandler.Android, which subtractsPeekAreaInsetsand 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
WidthMeasureSpecandHeightMeasureSpecare 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