maui icon indicating copy to clipboard operation
maui copied to clipboard

[Android] Fixed CollectionView MeasureFirstItem Rendering issue

Open Vignesh-SF3580 opened this issue 1 year ago • 7 comments

Root Cause

The problem occurred due to incorrect handling of pixel measurements, which caused rendering issues for the items in the CollectionView when using the ItemSizingStrategy as MeasureFirstItem.

Description of Change

The issue was caused by using FromPixels, which converts measurements based on screen density. This method was called twice during the measurement process, leading to a cumulative reduction in the width and height, which resulted in incorrect rendering of items in the CollectionView. The fix involved removing the unnecessary pixel conversion and using the raw _pixelSize values directly within the OnMeasure method. This change ensures that the width and height are measured correctly without being altered by screen density, preventing the rendering issues.

Tested the behaviour in the following platforms

  • [x] Android
  • [x] Windows
  • [x] iOS
  • [x] Mac

Issues Fixed

Fixes https://github.com/dotnet/maui/issues/25191

Screenshots

Before Issue Fix After Issue Fix
)

Vignesh-SF3580 avatar Oct 18 '24 07:10 Vignesh-SF3580

/azp run

PureWeen avatar Oct 20 '24 15:10 PureWeen

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Oct 20 '24 15:10 azure-pipelines[bot]

/azp run

PureWeen avatar Oct 21 '24 15:10 PureWeen

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Oct 21 '24 15:10 azure-pipelines[bot]

/azp run

jsuarezruiz avatar Oct 22 '24 12:10 jsuarezruiz

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Oct 22 '24 12:10 azure-pipelines[bot]

  • failing tests unrelated

PureWeen avatar Oct 22 '24 23:10 PureWeen