I'm trying to implement something like a fillViewP...
# compose
m
I'm trying to implement something like a fillViewPort functionality for scrollable content. Basically, I want the content to fill the remaining size of the screen when the content is not bigger than the screen, but I want to be able to scroll when the content is bigger, Does anyone know how to solve this issue?
c
My team's designer loves these kinds of layouts, but they were always such a pain to do in normal XML layouts. They're really simple in Compose though:
Copy code
Column(
    modifier = Modifier
        .fillMaxSize()
        .verticalScroll(rememberScrollState()),
) {
    TopContent()
    Spacer(Modifier.weight(1f))
    BottomContent()
}
❤️ 1
If
TopContent
is shorter than the
Column
, then
Spacer
will expand and push
BottomContent()
to the bottom of the container. If it's long, then
Spacer
will basically be 0dp tall, so
BottomContent
will be placed right after
TopContent
and the whole thing will scroll