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

Alignment

public fun interface Alignment

Known direct subclasses
BiasAbsoluteAlignment

An Alignment specified by bias: for example, a bias of -1 represents alignment to the left/top, a bias of 0 will represent centering, and a bias of 1 will represent right/bottom.

BiasAlignment

An Alignment specified by bias: for example, a bias of -1 represents alignment to the start/top, a bias of 0 will represent centering, and a bias of 1 will represent end/bottom.


An interface to calculate the position of a sized box inside an available space. Alignment is often used to define the alignment of a layout inside a parent layout.

See also
AbsoluteAlignment
BiasAlignment
BiasAbsoluteAlignment

Summary

Nested types

public static class Alignment.Companion

A collection of common Alignments aware of layout direction.

public fun interface Alignment.Horizontal

An interface to calculate the position of box of a certain width inside an available width.

public fun interface Alignment.Vertical

An interface to calculate the position of a box of a certain height inside an available height.

Public methods

abstract @NonNull IntOffset
align(
    @NonNull IntSize size,
    @NonNull IntSize space,
    @NonNull LayoutDirection layoutDirection
)

Calculates the position of a box of size size relative to the top left corner of an area of size space.

Public methods

align

abstract @NonNull IntOffset align(
    @NonNull IntSize size,
    @NonNull IntSize space,
    @NonNull LayoutDirection layoutDirection
)

Calculates the position of a box of size size relative to the top left corner of an area of size space. The returned offset can be negative or larger than space - size, meaning that the box will be positioned partially or completely outside the area.