Gabriel Stefan
02/23/2026, 7:26 PMModifier.weight inside a scrollable parent and I’d like to understand why it behaves the way it does.
Given a column with vertical scroll and a weighted child
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
) {
Box(
Modifier
.fillMaxWidth()
.height(200.dp)
.background(Color.Red)
)
Box(
Modifier
.weight(1f)
.fillMaxWidth()
.background(Color.Blue)
)
Box(
Modifier
.fillMaxWidth()
.height(200.dp)
.background(
Brush.linearGradient(
colors = listOf(Color(0xFF6366F1), Color(0xFFEC4899))
)
)
)
}
Based on the documentation around weight and expectations based on a simple understanding of how the modifier and scrolling works, this shouldn’t be possible, right? However when executed it looks as shown: the blue section takes up the remaining space after the gradient and red boxes are measured. Even though the incoming max constraint for each child is Infinity because of the verticalScroll. 🧵Gabriel Stefan
02/23/2026, 7:30 PMColumn the weighted space is collapsed and everything scrolls as normal
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
) {
Box(
Modifier
.fillMaxWidth()
.height(200.dp)
.background(Color.Red)
)
Box(
Modifier
.weight(1f)
.fillMaxWidth()
.background(Color.Blue)
)
Box(
Modifier
.fillMaxWidth()
.height(1000.dp)
.background(
Brush.linearGradient(
colors = listOf(Color(0xFF6366F1), Color(0xFFEC4899))
)
)
)
}Gabriel Stefan
02/23/2026, 7:31 PMGabriel Stefan
02/23/2026, 7:32 PMLouis Pullen-Freilich [G]
02/23/2026, 7:46 PM