Bitter
07/14/2025, 10:42 AMGridCells.Adaptive(100.dp)
and I am runnin the app which has the screen width of 350.dp . The compiler would identify that I can draw 3 columns , and 50dp would be left over .
What would happen to the left over space ? I am unable to utilize the left over space evenly despite horizontalArrangement .
LazyVerticalGrid(
modifier = Modifier.fillMaxWidth().background(Color.Blue),
horizontalArrangement = Arrangement.SpaceBetween,
columns = GridCells.Adaptive(100.dp)
) {
items(items) { room ->
RoomItem(room)
}
}
@Composable
fun RoomItem(room: RoomView) {
Box(
Modifier
.fillMaxWidth() // Fills the width of the column
.height(120.dp) // Give it a fixed height for visual clarity
.background(Color.Green) // This is the column's actual area
.padding(4.dp), // Some padding for visual separation
contentAlignment = Alignment.Center
) {
Text(text = "Room: ${room.name}", color = Color.White) // Just a placeholder
}
}
The code above yields the result in the screenshot. All my items are stacked after each other and the remaining space just appears at the end .Chrimaeon
07/14/2025, 10:51 AMBitter
07/14/2025, 10:53 AM