Repository navigation
fix(android): ContentLayout measures children against unreduced parent spec - #11439
Merged
NathanWalker merged 2 commits intoSep 23, 2026
Merged
Conversation
…t spec ContentLayout.onMeasure passed its own widthMeasureSpec/heightMeasureSpec straight to measureChild without deducting its own padding first, while onLayout does respect that padding. When ContentLayout carries padding (e.g. edge-to-edge system bar insets applied as padding on an ancestor), children measure against the full parent size but are laid out into the smaller padding box, and an ancestor with clipChildren=true silently clips the difference. StackLayout/DockLayout already reduce the spec by their own padding before measuring children; ContentLayout now does the same. Also fixes a latent onLayout typo where childBottom subtracted paddingRight instead of paddingTop, harmless only when horizontal and vertical padding happen to match.
|
View your CI Pipeline Execution ↗ for commit a50460a
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
The previous commit's onLayout change used (paddingTop + paddingBottom)
for childBottom, reasoning by analogy with the childTop/childBottom
naming. That's wrong: CommonLayoutParams.layoutChild's FILL_VERTICAL
branch passes the given top/bottom straight through to the child's
final bounds when there are no margins, so childTop already accounts
for paddingTop on its own and childBottom must not subtract it again.
Verified on-device: constructing a real ContentLayout with padding
(0/156/0/72) and a MATCH_PARENT child and comparing measured vs
laid-out height caught this immediately (measured 2628, laid out
2472) before it reached real usage. The correct computation only
drops paddingBottom, matching how childTop only adds paddingTop:
childBottom = bottom - top - paddingBottom;
Re-verified the same way: measured and laid-out heights now both
report 2628, matching the padded content box exactly.
NathanWalker
approved these changes
Sep 23, 2026
NathanWalker
deleted the
fix/android-contentlayout-child-measure-inset
branch
September 23, 2026 00:01
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ContentLayout.onMeasuremeasured children against its own unreduced parent spec, butonLayoutplaces them into the padding-reduced box. With padding present (e.g. edge-to-edge insets applied as padding at targetSdk 35+), children get laid out larger than their box and an ancestorclipChildren=truesilently clips the difference.StackLayout/DockLayout.onLayoutbug:childBottomincorrectly factored inpaddingRight. It must only subtractpaddingBottom(mirroring howchildToponly addspaddingTop) sinceCommonLayoutParams.layoutChild's FILL_VERTICAL branch passes top/bottom straight through to the child when there are no margins.widgets-release.aarandnative-build-state.jsonaccordingly.Test plan
./gradlew :widgets:compileReleaseJavaWithJavac./build.android.shrebuildnode tools/native-state.mjs check androidContentLayoutwith padding (0/156/0/72) and a MATCH_PARENT child directly via the compiled AAR, confirmed measured height now matches laid-out height (2628/2628, previously 2856/2628 mismatched)