Skip to content

[Android] Fixed the CollectionView Header and Footer Do Not Align with Horizontal ItemsLayout When EmptyView is Displayed" #28779

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

Merged
merged 2 commits into from
Apr 28, 2025

Conversation

Ahamed-Ali
Copy link
Contributor

Root Cause of the issue

  • When switching ItemsLayout to HorizontalList or HorizontalGrid, the empty view is incorrectly created with a vertical list layout because the ItemsLayout is not being properly considered when showing the empty view.

Description of Change

  • Updated the SetLayoutManager with the appropriate ItemsLayout.

Issues Fixed

Fixes #28622

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
ItemsLayoutIssue.mov
ItemsLayoutEmptyViewFix.mov

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

Hey there @@Ahamed-Ali! 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 Apr 3, 2025
@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review April 3, 2025 13:22
@Copilot Copilot AI review requested due to automatic review settings April 3, 2025 13:22
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner April 3, 2025 13:22
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 addresses a layout issue in CollectionView when an EmptyView is displayed for horizontal ItemsLayouts on Android. The key changes include:

  • Updating the ItemsLayout handling in MauiRecyclerView to select the appropriate layout manager.
  • Adding automated tests in TestCases.Shared.Tests to verify the layout behavior.
  • Updating the TestCases.HostApp UI to support the new layout behavior.

Reviewed Changes

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

File Description
Tests/Issues/Issue28622.cs Added automated test to verify ItemsLayout behavior with EmptyView
Issues/Issue28622.xaml.cs Updated UI interactions ensuring the correct ItemsLayout is applied
Core/Handlers/Items/Android/MauiRecyclerView.cs Modified layout manager selection to support horizontal ItemsLayout when EmptyView is displayed
Files not reviewed (1)
  • src/Controls/tests/TestCases.HostApp/Issues/Issue28622.xaml: Language not supported
Comments suppressed due to low confidence (2)

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

  • The preprocessor directives exclude iOS, Catalyst, and Windows tests but do not mention Android. Please ensure that the test is executed in an Android environment to verify the fix as described in the title.
#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS

src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs:579

  • Verify that 'SelectLayoutManager' correctly handles horizontal ItemsLayouts, ensuring that the EmptyView and header/footer align properly across all supported scenarios.
SetLayoutManager(SelectLayoutManager(ItemsLayout));

@jsuarezruiz jsuarezruiz added area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/android labels Apr 4, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Member

rmarinho commented Apr 7, 2025

/rebase

@rmarinho
Copy link
Member

rmarinho commented Apr 7, 2025

Missing screenshot
ItemsLayoutShouldRenderProperlyOnEmptyView

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

jsuarezruiz
jsuarezruiz previously approved these changes Apr 25, 2025
@PureWeen PureWeen changed the base branch from main to inflight/current April 28, 2025 15:20
@PureWeen PureWeen dismissed jsuarezruiz’s stale review April 28, 2025 15:20

The base branch was changed.

@PureWeen PureWeen merged commit f54a06f into dotnet:inflight/current Apr 28, 2025
128 checks passed
anandhan-rajagopal pushed a commit to anandhan-rajagopal/maui that referenced this pull request May 5, 2025
…h Horizontal ItemsLayout When EmptyView is Displayed" (dotnet#28779)

* Fixed the ItemsLayout issue with the EmptyView

* Committed the Android snap
PureWeen pushed a commit that referenced this pull request May 5, 2025
…h Horizontal ItemsLayout When EmptyView is Displayed" (#28779)

* Fixed the ItemsLayout issue with the EmptyView

* Committed the Android snap
PureWeen pushed a commit that referenced this pull request May 5, 2025
…h Horizontal ItemsLayout When EmptyView is Displayed" (#28779)

* Fixed the ItemsLayout issue with the EmptyView

* Committed the Android snap
PureWeen added a commit that referenced this pull request May 8, 2025
For more information about inflight process check
https://github.com/dotnet/maui/wiki/Inflight-Branch-Process

## .NET MAUI Release Notes - inflight/candidate

This document contains release notes for changes from main branch to
inflight/candidate branch.

### MAUI Product Fixes
* [iOS] Fix: FlyoutPage memory leak by @bhavanesh001 in
#28769
* [Windows] Fix for CarouselView IsSwipeEnabled=False Prevents Visual
Navigation by @SubhikshaSF4852 in
#29286
* [Windows] Fix for Argument Exception raised when the GetStringSize
method of ICanvas called with default font by @SyedAbdulAzeemSF4852 in
#29048
* Removed frame styles by @Vignesh-SF3580 in
#29222
* [Android] Fixed the CollectionView Header and Footer Do Not Align with
Horizontal ItemsLayout When EmptyView is Displayed by @Ahamed-Ali in
#28779
* Add global xmlns in template by @StephaneDelcroix in
#29203
* Fixed - On iOS GestureRecognizers don't work on Span in a Label, which
doesn't get IsVisible (=true) update from its parent by
@KarthikRajaKalaimani in #29024
* Fixed Footer not displayed at the Bottom When EmptyView in CV2 by
@Dhivya-SF4094 in #28681
* Fixed typo in Connectivity.shared.cs by @corvinsz in
#29213

### Testing
* Re-enabled flaky UI test TextInEditorShouldScroll by
@NirmalKumarYuvaraj in #29167
* [Testing] Re-Enabled UI Test - Issue10222Test by @TamilarasanSF4853 in
#29226
* [Testing] Feature Matrix UITest Cases for CollectionView Selection
Feature by @LogishaSelvarajSF4525 in
#29165

### Dependency Updates
*No dependency updates in this release*

### Docs
*No documentation changes in this release*

### Housekeeping
*No housekeeping changes in this release*

## New Contributors
* @corvinsz made their first contribution in
#29213

**Full Changelog**:
main...inflight/candidate
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request May 9, 2025
…h Horizontal ItemsLayout When EmptyView is Displayed" (dotnet#28779)

* Fixed the ItemsLayout issue with the EmptyView

* Committed the Android snap
@github-actions github-actions bot locked and limited conversation to collaborators May 29, 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
None yet
Development

Successfully merging this pull request may close these issues.

[Android] CollectionView Header and Footer Do Not Align with Horizontal ItemsLayout When EmptyView is Displayed
4 participants