Skip to content
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

[Android] Fixed ListView items height are not proper in initial loading with HasUnevenRows set as True. #26841

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,10 @@ protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
}

var size = _viewHandler.MeasureVirtualView(widthMeasureSpec, heightMeasureSpec);
height = (int)size.Height;
if (_viewCell.Height > 0)
height = (int)Context.ToPixels(_viewCell.Height);
else
height = (int)size.Height;
}
else
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue26820.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 26820, "ListView items height are not proper in initial loading with HasUnevenRows set as True", PlatformAffected.Android)]
public class Issue26820 : TestContentPage
{
ListView list;
StackLayout stackLayout;

ObservableCollection<Person1> Data;
public static int Count = 0;


protected override void Init()
{
list = new ListView() { AutomationId = "listView" };

var template = new DataTemplate(typeof(UnevenViewCell));
list.ItemTemplate = template;

Data = new ObservableCollection<Person1>();
list.ItemsSource = Data;
list.HasUnevenRows = true;

for (int i = 0; i < 50; i++)
{
Data.Add(new Person1
{
FullName = "Andrew",
Address = "404 Somewhere"
});
}



stackLayout = new StackLayout();
stackLayout.Children.Add(list);

this.Content = stackLayout;
}

}
class UnevenViewCell : ViewCell
{
public UnevenViewCell()
{

var label = new Label();
label.SetBinding(Label.TextProperty, "FullName");
Height = Issue26820.Count % 2 == 0 ? 50 : 100;
View = label;
View.BackgroundColor = Issue26820.Count % 2 == 0 ? Colors.Pink : Colors.LightYellow;
Issue26820.Count++;
}
}


class Person1
{
public string FullName { get; set; }
public string Address { get; set; }
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue26820 : _IssuesUITest
{

public Issue26820(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "ListView items height are not proper in initial loading with HasUnevenRows set as True";

[Test]
[Category(UITestCategories.ListView)]
public void ListViewShouldRenderProperRowHeight()
{
App.WaitForElement("listView");
VerifyScreenshot();

}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading