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

Ilias Zosimadis

02/07/2021, 10:37 AM
The problem with intrinsic size is that currently is not supported for SubcomposeLayout. So is there any other way to match the height of the Divider with the ComposableX?
a

Alex Bieliaiev

02/07/2021, 1:46 PM
My guess is that ConstraintLayout might help in that situation
You might try to link Divider's top and bottom anchors to the top and bottom of ComposableX
i

Ilias Zosimadis

02/07/2021, 3:22 PM
I believe that this only centers the divider around the ComposambleX, keeping the size fixed. What I want is to find the height of the parent before the divider's composition. Also, the row is inside a
lazyColumn
which measures each child with infinite max height constrain (because it allows a child to be as big as it wants) meaning that you can't just apply
fillMaxHeight
modifier.
j

Jan Bína

02/07/2021, 5:21 PM
Well, the ConstraintLayout is definitely an option, you would use
height = Dimension.fillToConstraints
in your
constrainAs
block so it's not only centered. If your usecase is really that simple, I would just use modifier for
ComposableX
, something like this:
Copy code
Modifier.drawBehind {
    drawLine(
        color = Color.Black,
        start = Offset(0F, 0F),
        end = Offset(0F, size.height),
        strokeWidth = 1.dp.toPx()
    )
}
👍 1
i

Ilias Zosimadis

02/07/2021, 5:54 PM
Yeah my bad, I forgot about the
fillToConstraints
. I also found a solution using a
SubcomposeLayout
which can be used to measure the size of a child composable and use it on the composition of a second child. I guess the ContraintLayout is the best solution but I am not sure yet. My use case is not just a Divider and a Composable so I can't use the
drawBehind
modifier.
👍 1