Skip to content

Conversation

@NanthiniMahalingam
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

  • [Android] CollectionView MeasureFirstItem ItemSizingStrategy Not Applied in Horizontal Layouts.

Root Cause

  • The first item's size was not applied correctly to subsequent items because the _pixelSize field was being set to null when using a horizontal orientation.

Description of Changes

  • Removed the assignment of null to the _pixelSize field, ensuring the first item's size is preserved and used for measuring subsequent items.
  • Introduced the UpdateAdapter method to re-measure and apply the first item’s size to all items when switching the layout orientation from vertical to horizontal.

Validated the behaviour in the following platforms

Issues Fixed

Fixes #29192

Output images

Android

Before After
Issue29192_Before.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label May 13, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@NanthiniMahalingam! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label May 13, 2025
@sheiksyedm sheiksyedm added area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android labels May 14, 2025
@NanthiniMahalingam NanthiniMahalingam marked this pull request as ready for review May 14, 2025 11:33
Copilot AI review requested due to automatic review settings May 14, 2025 11:33
@NanthiniMahalingam NanthiniMahalingam requested a review from a team as a code owner May 14, 2025 11:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request fixes an issue on Android where the CollectionView MeasureFirstItem sizing was not applied correctly in horizontal layouts. The changes ensure that the first item's size is preserved and correctly propagated, while also introducing an UpdateAdapter method to handle layout orientation changes.

  • Removed an unnecessary assignment that reset the first item's pixel size.
  • Updated the ItemsLayout mapping to call UpdateAdapter before updating the layout manager.
  • Added test cases to validate the fix on multiple platforms (Android, Windows, iOS, macOS).

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29192.cs Added test case for verifying MeasureFirstItem sizing in CollectionView.
src/Controls/tests/TestCases.HostApp/Issues/Issue29192.cs Introduced a sample ContentPage to test the horizontal layout behavior.
src/Controls/src/Core/Handlers/Items/StructuredItemsViewHandler.Android.cs Updated MapItemsLayout to call UpdateAdapter, ensuring correct adapter updates.
src/Controls/src/Core/Handlers/Items/Android/ItemContentView.cs Removed a duplicate assignment resetting _pixelSize to null.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test are failing, could verify if are related with the changes?
image

@NanthiniMahalingam
Copy link
Contributor Author

This test are failing, could verify if are related with the changes? image

Hi @jsuarezruiz ,

I've addressed the failing test case. Could you please verify it?

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@NanthiniMahalingam NanthiniMahalingam changed the title Fixed [Android] CollectionView MeasureFirstItem ItemSizingStrategy Not Applied in Horizontal Layouts [Android] Fixed CollectionView MeasureFirstItem ItemSizingStrategy Not Applied in Horizontal Layouts Jun 19, 2025
@jsuarezruiz
Copy link
Contributor

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] CollectionView with ItemSizingStrategy="MeasureFirstItem" Does Not Work as Expected for HorizontalList and HorizontalGrid Layouts

4 participants