feat(components): add SegmentWidthMode (Fill / Fit) to SegmentedContent#27
Merged
Conversation
Introduces a `widthMode` parameter so callers can choose between: - `Fill` (default) — bar expands to fill available width, existing behaviour - `Fit` — bar wraps to the natural width of its segments; only scrolls when they overflow Adds `IntrinsicSegmentRow` for the Fit+non-overflow path, updates `SegmentBar`'s SubcomposeLayout to report intrinsic width in Fit mode, conditionally applies `fillMaxWidth` on the Column and AnimatedContent, and guards even-distribution behind Fill mode. Preview, Showkase, and unit-test coverage included.
…ar when block and if-else
This was referenced Jun 6, 2026
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
SegmentWidthModeenum (Fill/Fit) and awidthModeparameter to bothSegmentedContentoverloads (default:Fill, preserving existing behaviour)Fill— bar expands to fill available width (current default)Fit— bar wraps to the natural width of its segments; scrolls only when they overflowIntrinsicSegmentRowfor the Fit + non-overflow path (plainRow, noweight(1f)/fillMaxWidth)SegmentBar'sSubcomposeLayoutnow reportstotalIntrinsicas its layout width in Fit mode and guards even-distribution behindFillmodefillMaxWidthonColumnandAnimatedContentis applied conditionallyTest plan
SegmentedContentTest,SegmentedContentInteractionTest)segmentWidthModeValuestest verifies enum stabilitySegmentedContentFitWidthPreviewrenders the bar at intrinsic width in Android Studio PreviewwidthMode = Fitand few short segments: bar is narrower than the screenwidthMode = Fitand many long segments (overflow): bar scrolls horizontally at full widthwidthMode = Fill) behaviour is unchanged across all existing previews