Repository navigation
[Android] Fix CollectionView ItemSpacing when items are added or removed at runtime #40318
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
Merged
kubaflo
merged 24 commits into
dotnet:inflight/11.0.1xx-sr3
from
marcelomoresco:fix/android-collectionview-itemspacing-runtime-items
Nov 18, 2026
+556
−12
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
20b30b5
Prepare normalized integration ancestry for 11.0.1xx SR2
github-actions[bot] b24f053
[Android]Fix keyboard-type flicker when replacing focused ContentView…
SuthiYuvaraj 206972c
[Windows] Fix Boxview shadow is not aligned with box view shape (#40175)
SubhikshaSf4851 b88d3ef
[net11] Recover lost Android emulator before UI test retry (#40273)
kubaflo 1624c52
[net11] Fail fast on Appium session creation after the device is lost…
kubaflo 66fce23
[Android] Fix CollectionView ItemSpacing when items are added or remo…
marcelomoresco ccf4b52
[Android] Invalidate ItemSpacing only on structural adapter changes
marcelomoresco 1843dbb
Prepare normalized integration ancestry for 11.0.1xx SR2
github-actions[bot] 3e0f22a
[Android]Fix keyboard-type flicker when replacing focused ContentView…
SuthiYuvaraj 219a32f
[Windows] Fix Boxview shadow is not aligned with box view shape (#40175)
SubhikshaSf4851 8fd2bac
[net11] Recover lost Android emulator before UI test retry (#40273)
kubaflo 2620692
[net11] Fail fast on Appium session creation after the device is lost…
kubaflo e4378ff
Add Android benchmarks for CollectionView ItemSpacing
marcelomoresco 75901d3
[Android] Invalidate ItemSpacing only for changes in the last row
marcelomoresco 605cb84
Don't keep a reference to the observed adapter in DataChangeObserver
marcelomoresco e318f6e
Merge net11 into fix/android-collectionview-itemspacing-runtime-items
marcelomoresco 04f1de1
Skip the spacing refresh when only the cross-axis spacing is set and …
marcelomoresco feb9e59
Check the spacing before counting items for the last-row filter
marcelomoresco 7c3c1f7
Test that a grouped insert without scrolling-axis spacing doesn't cou…
marcelomoresco 680bd72
Track the item count in the spacing observer instead of reading it pe…
marcelomoresco f5bbe7e
Read the item count for each last-row check instead of caching it
marcelomoresco 1129a3b
Take the spacing observer's item count from each layout pass
marcelomoresco 0733466
Test that an off-screen middle change doesn't recompute the visible s…
marcelomoresco 36d0085
Merge net11 into fix/android-collectionview-itemspacing-runtime-items
marcelomoresco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[moderate] CollectionView - Android - This reads the live adapter count, not a count synchronized with consumed notifications. ItemsSourceFactory leaves observable IEnumerable sources without IList unwrapped, and ObservableItemsSource dispatches their notifications while counting the live source. With one rendered item and ItemSpacing = 8, a worker can append twice after base.OnLayout computes the original item's zero bottom offset but before this read. ItemCount is then seeded with 3 while both insertions are queued. Their callbacks increment it to 4 and 5, so their exclusive ends 2 and 3 both fail ReachesLastRow and neither invalidates the original item's cached offsets. The subsequent layout resets the count without dirtying those offsets, leaving the half-spacing defect. Seed from notification-synchronized state, or preserve the unknown-count fallback when pending notifications cannot be excluded, and cover this layout/source interleaving.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same point as #40318 (comment): base.OnLayout reads the same live count for RecyclerView's own layout, so a source changed off the UI thread in that window is already out of sync with RecyclerView. Keeping it as is.