Skip to content

Conversation

Dhivya-SF4094
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 Detail

When using a LinearItemsLayout with a CarouselView on Android, the ItemSpacing will reduce the width of the elements in the CarouselView.

Root Cause

On Android, GetItemWidth() incorrectly subtracted ItemSpacing from the available width, causing items in CarouselView to appear narrower than intended.

Description of Change

Removed ItemSpacing from the item width calculation in GetItemWidth(). Item width is now calculated using only the available space minus PeekAreaInsets, ensuring consistent item sizing.

Validated the behaviour in the following platforms

Issues Fixed:

Fixes #29609

Screenshots

Before After
     

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

Hey there @@Dhivya-SF4094! 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 Jun 3, 2025
@Dhivya-SF4094 Dhivya-SF4094 changed the title Fixed ItemSpacing on CarouselView Fixed ItemSpacing on CarouselView resizes items [Android] Jun 3, 2025
@jsuarezruiz jsuarezruiz added platform/android area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Jun 3, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Dhivya-SF4094 Dhivya-SF4094 marked this pull request as ready for review June 3, 2025 11:56
@Copilot Copilot AI review requested due to automatic review settings June 3, 2025 11:56
@Dhivya-SF4094 Dhivya-SF4094 requested a review from a team as a code owner June 3, 2025 11:56
Copy link
Contributor

@Copilot 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 PR fixes the item sizing calculation for CarouselView on Android by removing the incorrect subtraction of ItemSpacing, and adds a UI test to verify that spacing no longer alters item width.

  • Removed ItemSpacing from the width and height calculations in GetItemWidth()/GetItemHeight() on Android
  • Added a new UI test in TestCases.Shared.Tests and corresponding view in TestCases.HostApp to verify correct behavior

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Controls/src/Core/Handlers/Items/CarouselViewHandler.Android.cs Adjusted width/height calculation to drop ItemSpacing subtraction
TestCases.Shared.Tests/Tests/Issues/Issue29609.cs Added UI test for spacing behavior (skipped on Windows)
TestCases.HostApp/Issues/Issue29609.cs Added sample page with CarouselView to exercise the spacing fix
Comments suppressed due to low confidence (1)

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29609.cs:1

  • The preprocessor directive has an extra space (# if); it should be #if TEST_FAILS_ON_WINDOWS to compile correctly.
# if TEST_FAILS_ON_WINDOWS // ItemSpacing on CarouselView is not applied on Windows https://github.com/dotnet/maui/issues/29772

@rmarinho
Copy link
Member

rmarinho commented Jun 4, 2025

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

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

Needs to update image for CarouselViewShouldRenderCorrectly

CarouselViewShouldRenderCorrectly

@Dhivya-SF4094
Copy link
Contributor Author

Needs to update image for CarouselViewShouldRenderCorrectly

@rmarinho Re-saved the screenshot for CarouselViewShouldRenderCorrectly.

@rmarinho
Copy link
Member

rmarinho commented Jun 6, 2025

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current June 6, 2025 15:27
@PureWeen PureWeen merged commit 2f6037b into dotnet:inflight/current Jun 6, 2025
3 of 78 checks passed
@PureWeen PureWeen added this to the .NET 9 SR9 milestone Jun 6, 2025
@PureWeen PureWeen moved this from Todo to Done in MAUI SDK Ongoing Jun 6, 2025
github-actions bot pushed a commit that referenced this pull request Jun 7, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
github-actions bot pushed a commit that referenced this pull request Jun 10, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
github-actions bot pushed a commit that referenced this pull request Jun 10, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
github-actions bot pushed a commit that referenced this pull request Jun 11, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
github-actions bot pushed a commit that referenced this pull request Jun 11, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
github-actions bot pushed a commit that referenced this pull request Jun 16, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
github-actions bot pushed a commit that referenced this pull request Jun 16, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
github-actions bot pushed a commit that referenced this pull request Jun 19, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
PureWeen added a commit that referenced this pull request Jun 21, 2025
For more information about inflight process check
https://github.com/dotnet/maui/wiki/Inflight-Branch-Process

# .NET MAUI Release Notes - inflight/candidate Branch

## MAUI Product Fixes
* [iOS] Fix SwipeView programmatic open when background color is set by
@Shalini-Ashokan in #29765
* [iOS] FormattedText with text color causes stack overflow - fix by
@kubaflo in #29874
* [iOS] Fix AdaptiveTrigger not working as expected by @jsuarezruiz in
#20987
* [iOS] Fix for Flyout title is not broken over multiple lines when you
rotate your screen by @BagavathiPerumal in
#29171
* [Windows] Fix for Assigning null to the SelectedItem of the
CollectionView in the SelectionChanged event does not clear the
selection by @SyedAbdulAzeemSF4852 in
#29288
* Fix TapCoordinates method in Catalyst by @jsuarezruiz in
#29775
* Fixed ItemSpacing on CarouselView resizes items [Android] by
@Dhivya-SF4094 in #29796
* Perf : ButtonContentTypeConverter now using InvariantCulture to parse
double by @antoine-jonathan in #25393
* ToolbarItem behavior with ImageSource iOS - fix by @kubaflo in
#28833
* [Android] Fixed Button Shadow Color Transparency Not Applied Correctly
by @NanthiniMahalingam in #29371
* Don't call NSAttributedString with HTML from a background thread by
@kubaflo in #26153
* [Windows] Implemented the Resize and Downsize functions in the
W2DImage class by @HarishwaranVijayakumar in
#29138
* Templated indicator view - improvements by @kubaflo in
#25642
* Update Issue25946.xaml by @anandhan-rajagopal in
#30025

## Testing
* Fixed Test case failure in PR 26153 - iOS by @kubaflo in
#29906
* Fixed Test case failure in PR 25642 - snapshots by @kubaflo in
#29881
* [Testing] Feature Matrix UITest Cases for RadioButton by
@TamilarasanSF4853 in #29744
* [Testing] Feature Matrix UITest Cases for CollectionView ItemsSource
Feature by @LogishaSelvarajSF4525 in
#29322
* [Testing] Feature Matrix UITest Cases for Stepper by
@nivetha-nagalingam in #29731
* [Testing] Feature Matrix UITest Cases for CheckBox Control by
@anandhan-rajagopal in #29739
* Update the comment for the test properties by @mattleibow in
#27306

## Dependency Updates
* No changes in this category

## Docs
* No changes in this category

## Housekeeping
* [create-pull-request] automated change by @github-actions[bot] in
#29875
* [create-pull-request] automated change by @github-actions[bot] in
#29792
* [create-pull-request] automated change by @github-actions[bot] in
#29760

**Full Changelog**:
origin/main...origin/inflight/candidate
rmarinho pushed a commit that referenced this pull request Jun 24, 2025
* Fixed ItemSpacing on CarouselView

* Added snapshot for Android and Mac

* Resaved image for CarouselViewShouldRenderCorrectly
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Android] ItemSpacing on CarouselView resizes items
4 participants