Nino
09/22/2025, 3:21 PMRow
(if they all fit horizontaly with 25% width each) or either 2 items (filling 50% width each) by row.
I see that you cannot measure twice in Layout.measurePolicy
, so the only way I see is giving twice the composables to my Layout so it can measure the "first one" (with 25% width constraints), and if I don't have enought space, measure the "second one" with the 50% width constraint). It completely defeats the purpose of "avoid exponential layout calculation" (the main reason why we can't measure twice if I understand) but I don't see any other way.
Any ideas? 💡
PS: I checked FlowRow but it's basically useless, it needs a fixed number of items per Row, which is dynamic in my case (2 or 4)Tgo1014
09/22/2025, 3:25 PMBoxWithContraints
, see the available width
and then decide between 2 or 4 and use a Grid or something like that?Nino
09/22/2025, 3:27 PMBoxWithContraints.maxWidth
isn't enoughZach Klippenstein (he/him) [MOD]
09/22/2025, 3:39 PMAlex Vanyo
09/22/2025, 5:12 PMFlowRow
to work - if you put each pair of items into a Row
, you could maybe get into a case where you have either 1 or 2 "pairs" per row.Alex Vanyo
09/22/2025, 5:13 PMNino
09/23/2025, 11:59 AMLayout
+ maxIntrinsicWidth
way, thank you all for your help!
Here's the result: https://gist.github.com/NinoDLC/9770237de84071e18e8f1c86ef60e03c
I'm not sure if I should override others functions than MultiContentMeasurePolicy.IntrinsicMeasureScope.minIntrinsicWidth
but for now it works. Thanks again!
PS: Good idea Alex but I didn't mention there was separators between items so it could not work in this case. But I'll def keep it in mind when separators are not needed 😄Nino
09/23/2025, 11:59 AMTgo1014
09/23/2025, 12:03 PMNino
09/23/2025, 12:15 PMZach Klippenstein (he/him) [MOD]
09/23/2025, 3:30 PMZach Klippenstein (he/him) [MOD]
09/23/2025, 3:31 PM