I’m trying to create a `Column` with a `VerticalSc...
# compose-desktop
a
I’m trying to create a
Column
with a
VerticalScrollBar
that grows with its contents until it reaches the maximum available space and then becomes scrollable. The code looks approximately like this:
Copy code
Box{
    Column(
        modifier = Modifier.verticalScroll(scrollState)
    ) {
        ...
    }
    VerticalScrollbar(
        modifier = Modifier.align(Alignment.CenterEnd).matchParentSize()
    )
}
Without the scrollbar, it works fine. Unfortunately, as soon as I add the scrollbar, it stretches the
Box
to fill all the available height. It doesn’t seem to respect the
matchParentSize
modifier.
Solved it in the meanwhile by noting the height of the box and column via
onGloballyPositioned
and only showing the scrollbar if the column is taller than the box.
t
You might be able to solve this with
Copy code
Modifier.height(IntrinsicSize.Min)
on the Box. Manually measuring usually takes two compositions to get things done, which may result in subtle jank. Your case is somewhat similar to the official exampe: https://developer.android.com/jetpack/compose/layouts/intrinsic-measurements#intrinsics-in-action