How to set height to `fillMaxHeight` inside compon...
# compose
v
How to set height to
fillMaxHeight
inside component where height is
wrapContentHeight
?
I try set
preferredHeight(IntrinsicSize.Min)
for parent, but if use
CoilImage
inside parent we have exception:
Intrinsic measurements are not currently supported by SubcomposeLayout
a
Those two should be fine to use together
v
Not work, also have exception
Intrinsic measurements are not currently supported by SubcomposeLayout
a
fillMaxHeight should work fine inside wrapContentHeight
v
Ok, I prepared sample
LazyColumnFor(items = listOf(1, 2, 3)) { item ->
Column(modifier = Modifier.fillMaxWidth()) {
Row(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.preferredHeight(IntrinsicSize.Min)
.padding(16.dp),
verticalGravity = Alignment.CenterVertically
) {
Box(
modifier = Modifier
.width(5.dp)
.fillMaxHeight(),
backgroundColor = Color.Cyan
)
Column(
modifier = Modifier.padding(start = 8.dp)
) {
ProvideEmphasis(emphasis = EmphasisAmbient.current.high) {
Text(
text = "App Name $item",
style = MaterialTheme.typography.subtitle1,
)
}
ProvideEmphasis(emphasis = EmphasisAmbient.current.medium) {
Text(
text = "App description",
style = MaterialTheme.typography.body2
)
}
}
}
Divider(
modifier = Modifier.padding(horizontal = 8.dp),
color = Color.DarkGray
)
}
}
It's basic sample
If I add
preferredHeight(IntrinsicSize.Min)
to Row
If removed
preferredHeight(IntrinsicSize.Min)
and add
CoilImage
as last child of Row
Copy code
CoilImage(
    data = "<https://picsum.photos/seed/123/300/300>",
    contentScale = ContentScale.Crop,
    modifier = Modifier
        .width(50.dp)
        .height(50.dp)
)
If add
preferredHeight(IntrinsicSize.Min)
to Row and add
CoilImage
as last child I have
java.lang.IllegalStateException: Intrinsic measurements are not currently supported by SubcomposeLayout
v
@Adam Powell
a
I see, so it is less about a wrap-content container and more about a container that has an unlimited max height
the most straightforward way to approach this is likely to be to add a modifier that draws the cyan indicator to the side of the Column that contains the text, or alternatively to the Row that holds everything
you want the size of the cyan bar to be the measured height of the content
take a look at the various border-related modifiers to see how they are implemented, a similar approach will likely be successful