tankistorep
04/02/2025, 9:12 AMText1 Separator Text2
If all of this doesn't fit on one line, then it should change to
Text1
Text2
Is there a way of doing this without using SubcomposeLayout? The usual advice is to use this when a composition of a child depends on a measurement of another, which I think applies here, but this layout seems way too simple to be using subcomposition.
The other solution I can think of is using Layout for all 3 of those Composables, but only placing the 2 Text Composables after measurements, but measuring 3 Composables and only placing 2 feels like an anti-patternStylianos Gakis
04/02/2025, 9:23 AMStylianos Gakis
04/02/2025, 9:24 AMtankistorep
04/02/2025, 9:41 AMSeparator is indeed a separate composable, not just spacingsindrenm
04/02/2025, 9:42 AMSeparator is indeed another composable that you only wish to render when there's space on one line for all three, then a custom Layout seems appropriate to me, too. Otherwise, if it's just spacing, a FlowRow might do the trick?Stylianos Gakis
04/02/2025, 9:43 AMtankistorep
04/02/2025, 10:02 AMSeparator in the Composition phase and half of the Layout stage (measurement), but then not in the second half (placing) and not in the drawing phase.
So whilst the solution would technically work, you still have the Separator node in the UI tree but it's not visually present. Which, I don't know if that would cause any side effects.
This is based on my understanding of how this works though, please feel free to correct my thinking 🙂sindrenm
04/02/2025, 10:03 AMtankistorep
04/02/2025, 10:35 AMsindrenm
04/02/2025, 11:49 AMkotlinforandroid
04/02/2025, 12:14 PMFlowRow with a bunch of Text elements, each being a "word".tankistorep
04/02/2025, 12:17 PMZach Klippenstein (he/him) [MOD]
04/02/2025, 2:32 PMZach Klippenstein (he/him) [MOD]
04/02/2025, 2:33 PMtankistorep
04/02/2025, 2:35 PM