I have a Column
that has a modifier with verticalScroll()
on it that fills the screen height. There are elements at the top and bottom of the column that have a third element centred between them using two spacers with weights of 1.0.
Occasionally elements may be added that make the column longer than the screen and activate the scroll. At that point the spacers shrink to nothing since they no longer need to fill space to fit the screen.
I've tried adding a height attribute in conjunction with the weight but that seems to have no effect. How do I have spacers fill space while also constraining to a height minimum?
Code:
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
.fillMaxHeight(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
PotentialOptionalElements()
PageHeader()
Spacer(Modifier.weight(1.0f))
PageContent()
Spacer(Modifier.weight(1.0f))
PageFooter()
}
Barring other options - The following works:
Spacer(Modifier.weight(1.0f))
Spacer(Modifier.height(16.dp))
Would however still prefer a solution that uses a single spacer