I'm trying to use `Layout` for the first time I'v...
# compose
d
I'm trying to use
Layout
for the first time I've set myself to build a fairly straight forward widget, but with a small circular dependency 2 components (the name is to help imagining but they can be whatever): • field • button the
button
can decide its own width but must match
field
height the
field
can decide its own height but must leave room for the
button
in it's width (
maxWidth - button.width
) the idea is the component will show the field and the button side by side filling width and wrapping height using the field. As far as I understood I can measure all components only once. If I measure
field
first I can adjust
button
width accordingly but I cannot make its height match
field
If I measure
button
first I can know it's width but I cannot tell it to take as much height as the
field
Can someone enlighten me on how to overcome a situation like this with Layout? thanks
z
Smells like a use case for intrinsics. Might not even need a custom layout. https://developer.android.com/jetpack/compose/layout#intrinsic-measurements
d
Thanks @Zach Klippenstein (he/him) [MOD] i didn't know about this!! Very useful!!