I'd like to measure the width of a hypothetical co...
# compose
r
I'd like to measure the width of a hypothetical composable, and then use that to set other widths. Is there a good way to do that? My layout looks like:
Row { Text(t1) Canvas Text(t2) }
. I want to measure a hypothetical
Text(longestPossibleString)
and use that to set width of the two Texts, so that things are centered and don't move as t1 and t2 change.
z
You could probably use MultiParagraphIntrinsics to measure your text
r
Mm. The docs for that say it calculates "width and height", but then it's only properties are
mix/maxIntrinsicWidth
. Where's the height?
z
Ah you said Row, so didn’t think you needed height. Take a look at the other classes in that package, might be something that gives you height
👍 1
r
Ah, right. I forgot and returned to this thread later with a different code situation. But you are correct, that package helps with both width and height. Eg,
Paragraph
.
👍 1