How to reach same behavior in Compose like MATCH_P...
# compose
i
How to reach same behavior in Compose like MATCH_PARENT in View Framework behave? modifier
fillMax...
looks pretty the same, but when it applied to child of container, that doesn’t have exact size, then child stretch the parent when i used view framework i can did like
Copy code
parent(wrap_content) {
   child(match_parent) // 1
   child(exact_size) // 2
}
and size of
1
was always the same as size of
2
. And when size of
2
changes size of
1
changes as well. Can i do the same in Compose?
t
I’m not 100% sure, but I guess you have to use IntrinsicMin in the parent composable: https://developer.android.com/jetpack/compose/layouts/intrinsic-measurements
i
I found also
Copy code
parent(modifier = Modifier.height(IntrinsicSize.Min)) {
   child(modifier = Modifier.fillMaxHeight()) // 1
   child(modifier = Modifier.height(exact)) // 2
}
But size of 1 doesn’t change when size of 2 do
Ok, looks like i need custom measurements
Thanks
j
Actually, IntrinsicMin should work here, unless you have composables down in the hierarchy that don't like intrinsic measuring, then i guess it gets ugly... Oh, in my case i didn't specify any exact heights. If you pass exact heights, why not pass them to all children?
i
I think i say wrong a bit. Exact size in my case is
wrap content
size, but it is less indeterminate, than parent size or child
1
size