Xamarin.forms: [Bug] CollectionView items do not resize properly when item template is grid (Regression from 4.7 to 4.8) (Android & iOS)

Created on 18 Sep 2020  路  6Comments  路  Source: xamarin/Xamarin.Forms

Description / Steps to Reproduce

Scenario: In a CollectionView draw a list of items that is a grid with two columns such that:

  1. The first column contains a StackLayout with two labels and the first label gets updated after the initial draw, possibly increasing it's length.
  2. The second column contains any element.

See the attached project for an example. Launch the app. Click on Browse. Wait about 5 seconds for the view to update.

Expected Behavior

When the update occurs, the items in the CollectionView resize so all of the content is shown. This works on 4.7.0.1351:

image

Actual Behavior

On 4.8.0.1451, the items change size but they get the wrong size which ends up with elements being cut off:

image

Notice how the item description line is cut off or hidden in a few of the rows. Unlike most other CollectionView item resize bugs, this happens on BOTH Android and iOS.

Basic Information

  • Version with issue: 4.8.0.1451
  • Last known good version: 4.7.0.1351
  • IDE: Visual Studio
  • Platform Target Frameworks:

    • iOS: 13

    • Android: 10.0

  • Android Support Library Version:
  • Nuget Packages: Minimal. Reproed with default Xamarin Project
  • Affected Devices: Pixel 3 Q 10.0 Emulator is where screenshots come from

Screenshots

See above

Reproduction Link

ItemSizingBugXF.zip

Workaround

None that I'm aware of. This is blocking an upgrade to 4.8

4.8.0 collectionview 6 regression in-progress Android iOS 馃崕 bug

Most helpful comment

@lafritay This was merged into 4.8, so it should be available in the next service release for 4.8.

All 6 comments

Is there any workaround for this?
We suddenly got reports on this from our customers and since we rely on certain 4.8 features I don't want to go through the hassle and downgrade Xamarin Forms while a proper fix is implemented

@modplug I'm not aware of a workaround. I'm using the workarounds mentioned in this issue (https://github.com/xamarin/xamarin.forms/issues/10842) for iOS and those didn't seem to immediately fix the problem but I didn't go very deep there and I didn't try to do something similar for Android.

@lafritay I'm looking at this bug now, and hopefully we can find a solution soon. In the meantime, in your repro project you can work around the issue by changing the height of your grid row from "*" to "Auto".

@hartez Thanks for the workaround. I was able to apply that to my app and get things working. While doing so, I did notice a layout issue even when Auto is used. I'm assuming they are related so I'm including the sample here.

App2.zip

Even though we're using Auto everywhere, notice that the description in rows 4 and 5 is still getting clipped:

image

Good luck with the fix!

@hartez Thanks for fixing this! Is there any chance this makes it to a 4.8.* servicing release since it was a regression? Or will we have to wait for 5.0.0?

@lafritay This was merged into 4.8, so it should be available in the next service release for 4.8.

Was this page helpful?
0 / 5 - 0 ratings