Repository navigation
Conversation
Contributor
Author
|
cc @riggaroo |
| val childHeight = if (height == Constraints.Infinity) { | ||
| Constraints.Infinity | ||
| } else { | ||
| (height - paddingPx * 2).coerceAtLeast(0) |
Contributor
There was a problem hiding this comment.
Suggest replacing paddingPx * 2 with variables horizontal and vertical to make it easier for understanding
Contributor
Author
There was a problem hiding this comment.
Done in 077f5b2. Added horizontal and vertical in minIntrinsicWidth to match measure.
| } else { | ||
| (height - paddingPx * 2).coerceAtLeast(0) | ||
| } | ||
| return measurable.minIntrinsicWidth(childHeight) + paddingPx * 2 |
Contributor
Author
srikrishnasakunia
approved these changes
Oct 28, 2026
This branch has not been deployed
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.
Code snippets for:
Replaces the
// Measure and layout here,// Logic hereandTODO()stubs inandroid_compose_intrinsics_custom_layoutandandroid_compose_intrinsics_custom_modifierwith working implementations. Today both bodies throwNotImplementedErrorinside excluded blocks and the rendered page shows only stub comments. The guide page is being updated separately to explain both overrides.android_compose_intrinsics_custom_layout:MyCustomComposableis implemented as a basic column that relaxesminHeightto0, measures each child, reports the widest child's width (or0when empty) and the sum of the heights coerced into the incoming constraints, and places the children vertically withplaceRelative. It overridesminIntrinsicHeight(width)instead ofminIntrinsicWidth(height): for a column where each child gets the full width, the minimum intrinsic height is the sum of the children'sminIntrinsicHeight(width).android_compose_intrinsics_custom_modifier:Modifier.myCustomModifier(padding: Dp = 8.dp)adds fixed padding on all sides.measureconvertspaddingto pixels, measures the child withconstraints.offset(-horizontal, -vertical), reports the child size plus the horizontal and vertical padding coerced intoconstraints, and places the child at(paddingPx, paddingPx).minIntrinsicWidth(height)subtracts the vertical padding fromheight(keepingConstraints.InfinityasConstraints.Infinityand clamping finite values to at least0), queriesmeasurable.minIntrinsicWidth(childHeight), and adds the horizontal padding.IntrinsicsCustomLayoutPreview: aprivate@Previewcomposable outside the snippet regions that callsIntrinsicsSnippet3.MyCustomComposablewithModifier.height(IntrinsicSize.Min)and twoTextchildren, applyingModifier.width(IntrinsicSize.Min).myCustomModifier(padding = 8.dp)to the second child.android_compose_intrinsics_custom_layoutmeasureandminIntrinsicWidthTODO()stubs with a working columnmeasureandminIntrinsicHeight(width)override (46 rendered lines vs 23 before)spotlessApplyandroid_compose_intrinsics_custom_modifier/* ... */parameter stub andmeasure/minIntrinsicWidthTODO()stubs withpadding: Dp = 8.dpand working implementations (35 rendered lines vs 22 before)spotlessApplyThe two existing
TwoTextsregions (android_compose_intrinsics_twotextsandandroid_compose_intrinsics_twotexts2) inIntrinsicSnippets.ktare unchanged. Every block on the page already comes from this file; nothing stays hardcoded.