athos
10/07/2021, 9:30 AMMIN_H
and MAX_H
. If the vertical available space is more than MAX_H
, the column should leave some empty space at the bottom, and if it is less than MIN_H
, the content will be scrollable. I thought I could get this quite easily with Modifier.heightIn()
but it doesn't matter where I put it or what I pass to it I never get the desired result. Example code in the thread.athos
10/07/2021, 9:31 AM@Composable
fun Test() {
Column(Modifier
.background(Color.Blue)
.verticalScroll(rememberScrollState())
.heightIn(min = 300.dp, max = 600.dp)
.fillMaxWidth()
) {
Text("one", Modifier
.fillMaxWidth()
.background(Color.Red)
.height(100.dp))
Text("two", Modifier
.fillMaxWidth()
.background(Color.Yellow)
.weight(1f))
Text("three", Modifier
.fillMaxWidth()
.background(Color.Green)
.height(100.dp))
}
}
EDIT: replacing heightIn
with requiredHeightIn
leads to the same results.athos
10/07/2021, 9:34 AMathos
10/07/2021, 9:34 AMJan Bína
10/07/2021, 10:04 AM.weight(1F, fill = false)
athos
10/07/2021, 10:23 AMathos
10/07/2021, 10:37 AMBoxWithConstraints
but it feels contrived:
@Composable
fun Test() {
BoxWithConstraints(Modifier.fillMaxSize()) {
Column(Modifier
.background(Color.Blue)
.verticalScroll(rememberScrollState())
.height(maxHeight.coerceIn(300.dp, 600.dp))
.fillMaxWidth()
) {
Text("one", Modifier
.fillMaxWidth()
.background(Color.Red)
.height(100.dp))
Text("two", Modifier
.fillMaxWidth()
.background(Color.Yellow)
.weight(1f))
Text("three", Modifier
.fillMaxWidth()
.background(Color.Green)
.height(100.dp))
}
}
}