diff --git a/src/Controls/src/Core/Handlers/Items/iOS/GridViewLayout.cs b/src/Controls/src/Core/Handlers/Items/iOS/GridViewLayout.cs
index 3330227909c2..bda227c7cc3e 100644
--- a/src/Controls/src/Core/Handlers/Items/iOS/GridViewLayout.cs
+++ b/src/Controls/src/Core/Handlers/Items/iOS/GridViewLayout.cs
@@ -243,7 +243,8 @@ bool NeedsSingleItemHorizontalAlignmentAdjustment(UICollectionViewLayoutAttribut
return false;
}
- if (layoutAttributesForRectElements[0].Frame.Top != CollectionView.Frame.Top + CollectionView.ContentInset.Bottom)
+ // We need to determine whether this 'if' statement is needed, as its relevance is currently uncertain.
+ if (layoutAttributesForRectElements[0].Frame.Top != CollectionView.Frame.Top)
{
return false;
}
diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CollectionViewSingleItemAlignmentWithFooter.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CollectionViewSingleItemAlignmentWithFooter.png
new file mode 100644
index 000000000000..13b2bb2daf8d
Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CollectionViewSingleItemAlignmentWithFooter.png differ
diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue21728.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue21728.xaml
new file mode 100644
index 000000000000..09fac4d85cef
--- /dev/null
+++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue21728.xaml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue21728.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue21728.xaml.cs
new file mode 100644
index 000000000000..da9a3efa0d7e
--- /dev/null
+++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue21728.xaml.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Microsoft.Maui.Controls;
+
+namespace Maui.Controls.Sample.Issues;
+
+[Issue(IssueTracker.Github, 21728, "CollectionView item alignment issue when a single item is present with a footer", PlatformAffected.iOS)]
+public partial class Issue21728 : ContentPage
+{
+ public IList Items { get; set; }
+
+ public Issue21728()
+ {
+ InitializeComponent();
+ BindingContext = this;
+ Items = new List();
+ Items.Add(new TestItem() { Name = "Test Item 1" });
+ collectionview.ItemsSource = Items;
+ }
+
+ public class TestItem
+ {
+ public string Name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21728.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21728.cs
new file mode 100644
index 000000000000..dcd86a00f205
--- /dev/null
+++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21728.cs
@@ -0,0 +1,26 @@
+#if !MACCATALYST
+using NUnit.Framework;
+using UITest.Appium;
+using UITest.Core;
+
+namespace Microsoft.Maui.TestCases.Tests.Issues
+{
+ public class Issue21728 : _IssuesUITest
+ {
+ public override string Issue => "CollectionView item alignment issue when a single item is present with a footer";
+
+ public Issue21728(TestDevice device)
+ : base(device)
+ { }
+
+ [Test]
+ [Category(UITestCategories.CollectionView)]
+ public void CollectionViewSingleItemAlignmentWithFooter()
+ {
+ App.WaitForElement("collectionview");
+
+ VerifyScreenshot();
+ }
+ }
+}
+#endif
diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CollectionViewSingleItemAlignmentWithFooter.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CollectionViewSingleItemAlignmentWithFooter.png
new file mode 100644
index 000000000000..79f72661d3af
Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/CollectionViewSingleItemAlignmentWithFooter.png differ
diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CollectionViewSingleItemAlignmentWithFooter.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CollectionViewSingleItemAlignmentWithFooter.png
new file mode 100644
index 000000000000..20deb6211b8d
Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CollectionViewSingleItemAlignmentWithFooter.png differ