maui
maui copied to clipboard
[Android] Fixed CollectionView MeasureFirstItem Rendering issue
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 |
|---|---|
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
- failing tests unrelated