https://kotlinlang.org logo
#compose
Title
# compose
a

Arun

11/24/2020, 9:02 PM
Trying to use
.preferredHeight(IntrinsicSize.Min)
. Getting the following error if a Composable using it is inside ScrollableColumn:
Copy code
java.lang.IllegalStateException: Intrinsic measurements are not currently supported by SubcomposeLayout
Any idea what this is and how to get around this? I’m currently on alpha07.
a

Adam Powell

11/24/2020, 9:12 PM
SubcomposeLayout is an implementation detail of a class of components that perform subcomposition during layout. Intrinsic measurements are a light-ish way of performing speculative measurement of a child - in other words, a way of querying child measurement parameters before performing the "real" measurement.
Since SubcomposeLayout doesn't know its contents until it is measured, it wouldn't be able to query intrinsic measurements without performing subcomposition - a fairly heavy-weight operation
so this is sort of protecting you from doing repeated layout that would become too expensive to scale well
as for how to get around it - determine which part of the composable that you're trying to apply
preferredHeight(IntrinsicSize.Min)
to is performing subcomposition and use a different tool there, or find another way to express your layout other than
preferred*(IntrinsicSize.*)
👍 1
a

Arun

11/24/2020, 9:19 PM
Oh ok. Got it. What would be your suggestion for recreating layouts such as in https://developer.android.com/codelabs/jetpack-compose-layouts#9 where the left and right item with respect to divider are fairly complex? ConstraintLayout?
a

Adam Powell

11/24/2020, 9:26 PM
a layout composable that has a way to express measurement ordering similar to how
Box
offers
Modifier.matchParentSize()
by annotating a child with parent data, a parent layout can decide which children determine the parent height and which children are measured using the results of the other children being measured
a

Arun

11/24/2020, 9:33 PM
Thanks for the suggestion 👍
6 Views