androidx.compose.ui
Alignment
Fun interface · from org.jetbrains.compose.ui:ui:1.12.2
Alignment says where a smaller thing goes inside a bigger area. There are three kinds, and parameters ask for the one they need:
| Kind | Values | Used by |
|---|---|---|
Alignment (both directions) |
TopStart, TopCenter, TopEnd, CenterStart, Center, CenterEnd, BottomStart, BottomCenter, BottomEnd |
Box contentAlignment, Modifier.align in a box |
Alignment.Horizontal |
Start, CenterHorizontally, End |
Column horizontalAlignment |
Alignment.Vertical |
Top, CenterVertically, Bottom |
Row verticalAlignment |
Start and End flip in right-to-left languages.
Along the main direction of a Row or Column, use Arrangement instead.
fun interface Alignment
Kinds of Alignment
Anywhere a Alignment is expected, you can pass any of these.
How to get one
Use the values below, like Alignment.Center or Alignment.CenterVertically.
Ready-made values and functions that return it
Or create one of the kinds listed above.
Used by
Parameters that take a Alignment.
animateFloatingActionButton(alignment)Box(contentAlignment)BoxScope.align(alignment)BoxWithConstraints(contentAlignment)GridScope.gridItem(alignment)Image(alignment)MenuDefaults.Label(contentAlignment)paint(alignment)Popup(alignment)PullToRefreshBox(contentAlignment)ToggleFloatingActionButton(contentAlignment)wrapContentSize(align)
Properties
TopStart
val TopStart: Alignment
Top, start corner.
TopCenter
val TopCenter: Alignment
Top edge, centered.
TopEnd
val TopEnd: Alignment
Top, end corner.
CenterStart
val CenterStart: Alignment
Start edge, centered vertically.
Center
val Center: Alignment
The middle.
CenterEnd
val CenterEnd: Alignment
End edge, centered vertically.
BottomStart
val BottomStart: Alignment
Bottom, start corner.
BottomCenter
val BottomCenter: Alignment
Bottom edge, centered.
BottomEnd
val BottomEnd: Alignment
Bottom, end corner.
Top
val Top: Vertical
Top. For vertical alignment in a row.
CenterVertically
val CenterVertically: Vertical
Centered vertically. For a row.
Bottom
val Bottom: Vertical
Bottom. For a row.
Start
val Start: Horizontal
Start. For horizontal alignment in a column.
CenterHorizontally
val CenterHorizontally: Horizontal
Centered horizontally. For a column.
End
val End: Horizontal
End. For a column.
Functions
align
fun align(
size: IntSize,
space: IntSize,
layoutDirection: LayoutDirection,
): IntOffset
Computes the position for a size inside a space. For custom layouts.