xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] CollectionView on Android does not layout new items properly #13054

Closed EvanMulawski closed 3 years ago

EvanMulawski commented 3 years ago

Description

When adding an item to the CollectionView's ItemsSource (bound to an ObservableCollection), the CollectionView layout's ItemSpacing property is not respected (using LinearItemsLayout).

Steps to Reproduce

  1. Without clearing or resetting the ItemsSource, add a new item to the backing data source.
  2. On Android, observe that the new item does not respect the ItemSpacing set on the CollectionView's layout.
  3. Triggering a layout pass by, for example, changing tabs, will resolve this.

Expected Behavior

The new items should be spaced as existing items are.

Actual Behavior

On Android, the new items do not respect the layout's ItemSpacing property.

Basic Information

Environment

Show/Hide ``` Microsoft Visual Studio Enterprise 2019 Version 16.8.2 VisualStudio.16.Release/16.8.2+30717.126 Microsoft .NET Framework Version 4.8.03752 Installed Version: Enterprise ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools ASA Service Provider 1.0 ASP.NET and Web Tools 2019 16.8.553.28003 ASP.NET and Web Tools 2019 ASP.NET Core Razor Language Services 16.1.0.2052803+84e121f1403378489b842e1797df2f3f5a49ac3c Provides languages services for ASP.NET Core Razor. ASP.NET Web Frameworks and Tools 2019 16.8.553.28003 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 16.8.553.28003 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.6.1000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 16.8.553.28003 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.6.1000.0 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 3.8.0-5.20567.16+53c5d7d3cf13d88978744a32a27c5f8350a8400a C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events GitHub.VisualStudio 2.11.106.19330 A Visual Studio Extension that brings the GitHub Flow into Visual Studio. IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info Microsoft Azure HDInsight Azure Node 2.6.1000.0 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.6.1000.0 Language service for Hive query Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio Microsoft Azure Stream Analytics Language Service 2.6.1000.0 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30924.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 2.1.113+g422d40002e.RR Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Mono Debugging for Visual Studio 16.8.43 (00471f8) Support for debugging Mono processes with Visual Studio. Node.js Tools 1.5.20902.1 Commit Hash:b474efcb6f92db52a8f8e2e6a8cb9648476885cc Adds support for developing and debugging Node.js apps in Visual Studio NuGet Package Manager 5.8.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Redgate SQL Change Automation 4.3.20316.22971 Extend DevOps processes to your SQL Server databases and safely automate database deployments. Visit https://www.red-gate.com/sca/productpage for more information. Copyright (C) 2011 Red Gate Software Ltd. All rights reserved. This software contains components from Component Owl. SQL Server is a registered trademark of Microsoft Corporation. Visual Studio is a registered trademark of Microsoft Corporation. SQL Change Automation contains code from the following open source software: NuGet https://www.nuget.org/ SQL LocalDB Wrapper https://github.com/martincostello/sqllocaldb Autofac https://autofac.org/ Json.NET https://json.net/ SemVer https://github.com/maxhauser/semver Serilog https://serilog.net/ StringTemplate https://github.com/antlr/stringtemplate4 Extended WPF Toolkit https://wpftoolkit.codeplex.com/ Code InfoBox VSX http://www.codeproject.com/Articles/55196/Code-InfoBox-Visual-Studio-Extension-VSX OctoPack https://github.com/OctopusDeploy/OctoPack SQLite https://sqlite.org/ This product contains icons from http://www.visualpharm.com distributed under a free backlink license. For license details or other notices relating to the above software, please see NOTICE.TXT and EULA.rtf in the SQL Change Automation application folder. Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info SonarLint for Visual Studio 4.28.0.24595 SonarLint is an extension to your favorite IDE that provides on-the-fly feedback to developers on new bugs and quality issues injected into their code. SQL Server Data Tools 16.0.62010.06180 Microsoft SQL Server Data Tools ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 16.0.21016.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 3.8.0-5.20567.16+53c5d7d3cf13d88978744a32a27c5f8350a8400a Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 16.8.0-beta.20507.4+da6be68280c89131cdba2045525b80890401defd Microsoft Visual F# Tools Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Container Tools Extensions 1.0 View, manage, and diagnose containers within Visual Studio. Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Foo 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 16.8.000.255 (d16-8@d002176) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.8.0.507 (remotes/origin/d16-8@e87b24884) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.8.112 (86385a3) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 11.1.0.17 (d16-8/c0e2b8e) Xamarin.Android Reference Assemblies and MSBuild support. Mono: be2226b Java.Interop: xamarin/java.interop/d16-8@79d9533 ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000 SQLite: xamarin/sqlite/3.32.1@1a3276b Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc Xamarin.iOS and Xamarin.Mac SDK 14.4.1.3 (e30c41de3) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ```

Screenshots

Before adding a new item: image

After adding a new item: image

Reproduction Link

https://github.com/EvanMulawski/XamarinFormsIssues/tree/master/XFIssues/XFIssues/XF13054

Workaround

EvanMulawski commented 3 years ago

Added repro

EvanMulawski commented 3 years ago

Possibly fixed by https://github.com/xamarin/Xamarin.Forms/pull/10624 ?

PureWeen commented 3 years ago

I pulled down the nuget for #10624 and it looks like it fixes it!