FlowColumn

Functions summary

Unit
@Composable
FlowColumn(
    modifier: Modifier,
    verticalArrangement: Arrangement.Vertical,
    horizontalArrangement: Arrangement.Horizontal,
    itemHorizontalAlignment: Alignment.Horizontal,
    maxItemsInEachColumn: Int,
    maxLines: Int,
    content: @Composable FlowColumnScope.() -> Unit
)

FlowColumn is a layout that fills items from top to bottom, and when it runs out of space on the bottom, moves to the next "column" or "line" on the right or left based on ltr or rtl layouts, and then continues filling items from top to bottom.

Cmn
Unit
@Composable
@ExperimentalLayoutApi
FlowColumn(
    modifier: Modifier,
    verticalArrangement: Arrangement.Vertical,
    horizontalArrangement: Arrangement.Horizontal,
    itemHorizontalAlignment: Alignment.Horizontal,
    maxItemsInEachColumn: Int,
    maxLines: Int,
    overflow: FlowColumnOverflow,
    content: @Composable FlowColumnScope.() -> Unit
)

This function is deprecated. The overflow parameter has been deprecated

Cmn

Functions

@Composable
fun FlowColumn(
    modifier: Modifier = Modifier,
    verticalArrangement: Arrangement.Vertical = Arrangement.Top,
    horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
    itemHorizontalAlignment: Alignment.Horizontal = Alignment.Start,
    maxItemsInEachColumn: Int = Int.MAX_VALUE,
    maxLines: Int = Int.MAX_VALUE,
    content: @Composable FlowColumnScope.() -> Unit
): Unit

FlowColumn is a layout that fills items from top to bottom, and when it runs out of space on the bottom, moves to the next "column" or "line" on the right or left based on ltr or rtl layouts, and then continues filling items from top to bottom.

It supports ltr in LTR layouts, by placing the first column to the left, and then moving to the right It supports rtl in RTL layouts, by placing the first column to the right, and then moving to the left

Example:

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.FlowColumn
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

Text(
    modifier =
        Modifier.fillMaxWidth(1f).padding(20.dp).wrapContentHeight(align = Alignment.Top),
    text = "FlowColumn with weights",
    fontWeight = FontWeight.Bold,
)

FlowColumn(
    Modifier.padding(20.dp)
        .fillMaxWidth()
        .padding(20.dp)
        .wrapContentHeight(align = Alignment.Top)
        .height(200.dp)
        .border(BorderStroke(2.dp, Color.Gray)),
    horizontalArrangement = Arrangement.spacedBy(10.dp),
    verticalArrangement = Arrangement.spacedBy(20.dp),
    maxItemsInEachColumn = 3,
) {
    repeat(17) { index ->
        Box(
            Modifier.align(Alignment.CenterHorizontally)
                .width(50.dp)
                .height(50.dp)
                .weight(1f, true)
                .background(color = Color.Green)
        ) {
            Text(text = index.toString(), fontSize = 18.sp, modifier = Modifier.padding(3.dp))
        }
    }
}

When a Modifier ColumnScope.weight is provided, it scales the item based on the number items that fall on the column it was placed in.

Parameters
modifier: Modifier = Modifier

The modifier to be applied to the Row.

verticalArrangement: Arrangement.Vertical = Arrangement.Top

The vertical arrangement of the layout's children.

horizontalArrangement: Arrangement.Horizontal = Arrangement.Start

The horizontal arrangement of the layout's virtual columns

itemHorizontalAlignment: Alignment.Horizontal = Alignment.Start

The cross axis/horizontal alignment of an item in the column.

maxItemsInEachColumn: Int = Int.MAX_VALUE

The maximum number of items per column

maxLines: Int = Int.MAX_VALUE

The max number of rows

content: @Composable FlowColumnScope.() -> Unit

The content as a ColumnScope

See also
FlowRow
Column

FlowColumn

@Composable
@ExperimentalLayoutApi
fun FlowColumn(
    modifier: Modifier = Modifier,
    verticalArrangement: Arrangement.Vertical = Arrangement.Top,
    horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
    itemHorizontalAlignment: Alignment.Horizontal = Alignment.Start,
    maxItemsInEachColumn: Int = Int.MAX_VALUE,
    maxLines: Int = Int.MAX_VALUE,
    overflow: FlowColumnOverflow = FlowColumnOverflow.Clip,
    content: @Composable FlowColumnScope.() -> Unit
): Unit

FlowColumn is a layout that fills items from top to bottom, and when it runs out of space on the bottom, moves to the next "column" or "line" on the right or left based on ltr or rtl layouts, and then continues filling items from top to bottom.

It supports ltr in LTR layouts, by placing the first column to the left, and then moving to the right It supports rtl in RTL layouts, by placing the first column to the right, and then moving to the left

Example:

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.FlowColumn
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

Text(
    modifier =
        Modifier.fillMaxWidth(1f).padding(20.dp).wrapContentHeight(align = Alignment.Top),
    text = "FlowColumn with weights",
    fontWeight = FontWeight.Bold,
)

FlowColumn(
    Modifier.padding(20.dp)
        .fillMaxWidth()
        .padding(20.dp)
        .wrapContentHeight(align = Alignment.Top)
        .height(200.dp)
        .border(BorderStroke(2.dp, Color.Gray)),
    horizontalArrangement = Arrangement.spacedBy(10.dp),
    verticalArrangement = Arrangement.spacedBy(20.dp),
    maxItemsInEachColumn = 3,
) {
    repeat(17) { index ->
        Box(
            Modifier.align(Alignment.CenterHorizontally)
                .width(50.dp)
                .height(50.dp)
                .weight(1f, true)
                .background(color = Color.Green)
        ) {
            Text(text = index.toString(), fontSize = 18.sp, modifier = Modifier.padding(3.dp))
        }
    }
}

When a Modifier ColumnScope.weight is provided, it scales the item based on the number items that fall on the column it was placed in.

Parameters
modifier: Modifier = Modifier

The modifier to be applied to the Row.

verticalArrangement: Arrangement.Vertical = Arrangement.Top

The vertical arrangement of the layout's children.

horizontalArrangement: Arrangement.Horizontal = Arrangement.Start

The horizontal arrangement of the layout's virtual columns

itemHorizontalAlignment: Alignment.Horizontal = Alignment.Start

The cross axis/horizontal alignment of an item in the column.

maxItemsInEachColumn: Int = Int.MAX_VALUE

The maximum number of items per column

maxLines: Int = Int.MAX_VALUE

The max number of rows

overflow: FlowColumnOverflow = FlowColumnOverflow.Clip

The strategy to handle overflowing items

content: @Composable FlowColumnScope.() -> Unit

The content as a ColumnScope