{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

Arrangement

public static class Arrangement


Used to specify the arrangement of the layout's children in layouts like Row or Column in the main axis direction (horizontal and vertical, respectively).

Below is an illustration of different horizontal arrangements in Rows: Row arrangements

Different vertical arrangements in Columns: Column arrangements

Summary

Nested types

public static class Arrangement.Absolute
public interface Arrangement.Horizontal

Used to specify the horizontal arrangement of the layout's children in layouts like Row.

Used to specify the horizontal arrangement of the layout's children in horizontal layouts like Row, or the vertical arrangement of the layout's children in vertical layouts like Column.

public interface Arrangement.Vertical

Used to specify the vertical arrangement of the layout's children in layouts like Column.

Public fields

static @NonNull Arrangement

Public methods

final @NonNull Arrangement.Horizontal

Place children horizontally one next to the other and align the obtained group according to an alignment.

final @NonNull Arrangement.Vertical

Place children vertically one next to the other and align the obtained group according to an alignment.

final @NonNull Arrangement.Vertical

Place children vertically such that they are as close as possible to the bottom of the main axis.

final @NonNull Arrangement.HorizontalOrVertical

Place children such that they are as close as possible to the middle of the main axis.

final @NonNull Arrangement.Horizontal

Place children horizontally such that they are as close as possible to the end of the main axis.

final @NonNull Arrangement.HorizontalOrVertical

Place children such that they are spaced evenly across the main axis, including free space before the first child and after the last child, but half the amount of space existing otherwise between two consecutive children.

final @NonNull Arrangement.HorizontalOrVertical

Place children such that they are spaced evenly across the main axis, without free space before the first child or after the last child.

final @NonNull Arrangement.HorizontalOrVertical

Place children such that they are spaced evenly across the main axis, including free space before the first child and after the last child.

final @NonNull Arrangement.Horizontal

Place children horizontally such that they are as close as possible to the beginning of the horizontal axis (left if the layout direction is LTR, right otherwise).

final @NonNull Arrangement.Vertical

Place children vertically such that they are as close as possible to the top of the main axis.

final @NonNull Arrangement.HorizontalOrVertical

Place children such that each two adjacent ones are spaced by a fixed space distance across the main axis.

final @NonNull Arrangement.Horizontal

Place children horizontally such that each two adjacent ones are spaced by a fixed space distance.

final @NonNull Arrangement.Vertical

Place children vertically such that each two adjacent ones are spaced by a fixed space distance.

Public fields

INSTANCE

public static @NonNull Arrangement INSTANCE

Public methods

aligned

public final @NonNull Arrangement.Horizontal aligned(@NonNull Alignment.Horizontal alignment)

Place children horizontally one next to the other and align the obtained group according to an alignment.

Parameters
@NonNull Alignment.Horizontal alignment

The alignment of the children inside the parent.

aligned

public final @NonNull Arrangement.Vertical aligned(@NonNull Alignment.Vertical alignment)

Place children vertically one next to the other and align the obtained group according to an alignment.

Parameters
@NonNull Alignment.Vertical alignment

The alignment of the children inside the parent.

getBottom

public final @NonNull Arrangement.Vertical getBottom()

Place children vertically such that they are as close as possible to the bottom of the main axis. Visually: (top) ####123 (bottom)

getCenter

public final @NonNull Arrangement.HorizontalOrVertical getCenter()

Place children such that they are as close as possible to the middle of the main axis. Visually: ##123## for LTR and ##321## for RTL.

getEnd

public final @NonNull Arrangement.Horizontal getEnd()

Place children horizontally such that they are as close as possible to the end of the main axis. Visually: ####123 for LTR and 321#### for RTL.

getSpaceAround

public final @NonNull Arrangement.HorizontalOrVertical getSpaceAround()

Place children such that they are spaced evenly across the main axis, including free space before the first child and after the last child, but half the amount of space existing otherwise between two consecutive children. Visually: #1##2##3# for LTR and #3##2##1# for RTL

getSpaceBetween

public final @NonNull Arrangement.HorizontalOrVertical getSpaceBetween()

Place children such that they are spaced evenly across the main axis, without free space before the first child or after the last child. Visually: 1##2##3 for LTR or 3##2##1 for RTL.

getSpaceEvenly

public final @NonNull Arrangement.HorizontalOrVertical getSpaceEvenly()

Place children such that they are spaced evenly across the main axis, including free space before the first child and after the last child. Visually: #1#2#3# for LTR and #3#2#1# for RTL.

getStart

public final @NonNull Arrangement.Horizontal getStart()

Place children horizontally such that they are as close as possible to the beginning of the horizontal axis (left if the layout direction is LTR, right otherwise). Visually: 123#### for LTR and ####321.

getTop

public final @NonNull Arrangement.Vertical getTop()

Place children vertically such that they are as close as possible to the top of the main axis. Visually: (top) 123#### (bottom)

spacedBy

public final @NonNull Arrangement.HorizontalOrVertical spacedBy(@NonNull Dp space)

Place children such that each two adjacent ones are spaced by a fixed space distance across the main axis. The spacing will be subtracted from the available space that the children can occupy. The space can be negative, in which case children will overlap.

To change alignment of the spaced children horizontally or vertically, use spacedBy overloads with alignment parameter.

Parameters
@NonNull Dp space

The space between adjacent children.

spacedBy

public final @NonNull Arrangement.Horizontal spacedBy(@NonNull Dp space, @NonNull Alignment.Horizontal alignment)

Place children horizontally such that each two adjacent ones are spaced by a fixed space distance. The spacing will be subtracted from the available width that the children can occupy. An alignment can be specified to align the spaced children horizontally inside the parent, in case there is empty width remaining. The space can be negative, in which case children will overlap.

Parameters
@NonNull Dp space

The space between adjacent children.

@NonNull Alignment.Horizontal alignment

The alignment of the spaced children inside the parent.

spacedBy

public final @NonNull Arrangement.Vertical spacedBy(@NonNull Dp space, @NonNull Alignment.Vertical alignment)

Place children vertically such that each two adjacent ones are spaced by a fixed space distance. The spacing will be subtracted from the available height that the children can occupy. An alignment can be specified to align the spaced children vertically inside the parent, in case there is empty height remaining. The space can be negative, in which case children will overlap.

Parameters
@NonNull Dp space

The space between adjacent children.

@NonNull Alignment.Vertical alignment

The alignment of the spaced children inside the parent.