Column
@Composable
inline fun Column(
modifier: Modifier = Modifier,
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
content: @Composable ColumnScope.() -> Unit,
)
A layout composable that places its children in a vertical sequence. For a layout composable that
places its children in a horizontal sequence, see Row
. Note that by default items do not
scroll; see Modifier.verticalScroll
to add this behavior. For a vertically scrollable list that
only composes and lays out the currently visible items see LazyColumn
.
The Column
layout is able to assign children heights according to their weights provided using
the ColumnScope.weight
modifier. If a child is not provided a weight, it will be asked for its
preferred height before the sizes of the children with weights are calculated proportionally to
their weight based on the remaining available space. Note that if the Column
is vertically
scrollable or part of a vertically scrollable container, any provided weights will be disregarded
as the remaining available space will be infinite.
When none of its children have weights, a Column
will be as small as possible to fit its
children one on top of the other. In order to change the height of the Column
, use the
Modifier.height
modifiers; e.g. to make it fill the available height Modifier.fillMaxHeight
can be used. If at least one child of a Column
has a weight
, the Column
will fill the available height, so there is no need for Modifier.fillMaxHeight
. However, if
Column
's size should be limited, the Modifier.height
or Modifier.size
layout modifiers
should be applied.
When the size of the Column
is larger than the sum of its children sizes, a
verticalArrangement
can be specified to define the positioning of the children inside the
Column
. See Arrangement
for available positioning behaviors; a custom arrangement can also be
defined using the constructor of Arrangement
. Below is an illustration of different vertical
arrangements:
!Column arrangements
(https://developer.android.com/images/reference/androidx/compose/foundation/layout/column_arrangement_visualization.gif)
Parameters
modifier | The modifier to be applied to the Column. |
verticalArrangement | The vertical arrangement of the layout's children. |
horizontalAlignment | The horizontal alignment of the layout's children. |
content | The content of the Column |