Fill max width inside FlowRow - jetpack compose

1.2k Views Asked by At

I to want a row where the items goes to the next line if it gets to small. Fair enough, i am using FlowRow for that.

I want the items to take up the space on the line they are on. Ok, tried to use weight, but thats not possible.

So how can i create a Row that both goes to the next line when reaching a size limit, but also make it fill the whole possible width?

1

There are 1 best solutions below

0
Anna Arroyo On

According to the documentation for FlowRow it should behave this way automatically but adding a modifier to fill the max width might solve your issue. Here is the code snippet form the documentation with fillMaxWidth():

Column() {
    FlowRow(
        Modifier
            .fillMaxWidth(1f)
            .wrapContentHeight(align = Alignment.Top)
            .border(BorderStroke(2.dp, Color.Gray)),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.Start,
        maxItemsInEachRow = 3
    ) 
    ....
}