Skip to content

Commit f54a06f

Browse files
authored
[Android] Fixed the CollectionView Header and Footer Do Not Align with Horizontal ItemsLayout When EmptyView is Displayed" (#28779)
* Fixed the ItemsLayout issue with the EmptyView * Committed the Android snap
1 parent 7bd86e3 commit f54a06f

File tree

5 files changed

+85
-1
lines changed

5 files changed

+85
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ internal void UpdateEmptyViewVisibility()
576576
SwapAdapter(_emptyViewAdapter, true);
577577

578578
// TODO hartez 2018/10/24 17:34:36 If this works, cache this layout manager as _emptyLayoutManager
579-
SetLayoutManager(new LinearLayoutManager(Context));
579+
SetLayoutManager(SelectLayoutManager(ItemsLayout));
580580
UpdateEmptyView();
581581
}
582582
else if (!showEmptyView && currentAdapter != ItemsViewAdapter)
45 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage
3+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
5+
x:Class="Maui.Controls.Sample.Issues.Issue28622">
6+
<Grid RowDefinitions="100,Auto,Auto,Auto,Auto">
7+
<CollectionView x:Name="collectionView"
8+
BackgroundColor="Gray">
9+
</CollectionView>
10+
<Button Clicked="OnLayoutButtonClicked"
11+
AutomationId="LayoutButton"
12+
Grid.Row="1"
13+
Text="Change Itemslayout"/>
14+
<Button Clicked="OnHeaderButtonClicked"
15+
AutomationId="HeaderButton"
16+
Grid.Row="2"
17+
Text="Add Header"/>
18+
<Button Clicked="OnFooterButtonClicked"
19+
AutomationId="FooterButton"
20+
Grid.Row="3"
21+
Text="Add Footer"/>
22+
<Button Clicked="OnEmptyViewButtonClicked"
23+
AutomationId="EmptyViewButton"
24+
Grid.Row="4"
25+
Text="Add EmptyView"/>
26+
</Grid>
27+
</ContentPage>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 28622, "[Android] CollectionView Header and Footer Do Not Align with Horizontal ItemsLayout When EmptyView is Displayed", PlatformAffected.Android)]
4+
public partial class Issue28622 : ContentPage
5+
{
6+
public Issue28622()
7+
{
8+
InitializeComponent();
9+
}
10+
11+
private void OnLayoutButtonClicked(object sender, EventArgs e)
12+
{
13+
collectionView.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal);
14+
}
15+
16+
private void OnHeaderButtonClicked(object sender, EventArgs e)
17+
{
18+
collectionView.Header = "CollectionView Header(String)";
19+
}
20+
21+
private void OnFooterButtonClicked(object sender, EventArgs e)
22+
{
23+
collectionView.Footer = "CollectionView Footer(String)";
24+
}
25+
26+
private void OnEmptyViewButtonClicked(object sender, EventArgs e)
27+
{
28+
collectionView.EmptyView = "EmptyView String";
29+
}
30+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS
2+
//https://github.com/dotnet/maui/issues/27946 In Windows, dynamically changing the ItemsLayout does not work.
3+
// https://github.com/dotnet/maui/issues/28678 On iOS and Mac, in Cv2, changing the ItemsLayout throws an exception. In Cv1, the EmptyView overlaps.
4+
using NUnit.Framework;
5+
using UITest.Appium;
6+
using UITest.Core;
7+
8+
namespace Microsoft.Maui.TestCases.Tests.Issues;
9+
public class Issue28622 : _IssuesUITest
10+
{
11+
public Issue28622(TestDevice device) : base(device) { }
12+
13+
public override string Issue => "[Android] CollectionView Header and Footer Do Not Align with Horizontal ItemsLayout When EmptyView is Displayed";
14+
15+
[Test]
16+
[Category(UITestCategories.CollectionView)]
17+
public void ItemsLayoutShouldRenderProperlyOnEmptyView()
18+
{
19+
App.WaitForElement("LayoutButton");
20+
App.Tap("LayoutButton");
21+
App.Tap("HeaderButton");
22+
App.Tap("FooterButton");
23+
App.Tap("EmptyViewButton");
24+
VerifyScreenshot();
25+
}
26+
}
27+
#endif

0 commit comments

Comments
 (0)