Android 12 Developer Preview is here! Try it out, and give us your feedback!

androidx.compose.ui.unit

Interfaces

Density

A density of the screen.

Classes

Constraints

Immutable constraints used for measuring layouts, usually as part of parent layouts or layout modifiers.

Dp

Dimension value representing device-independent pixels (dp).

DpOffset

A two-dimensional offset using Dp for units

DpRect

A four dimensional bounds using Dp for units

IntOffset

A two-dimensional position using Int pixels for units

IntRect

An immutable, 2D, axis-aligned, integer bounds rectangle whose coordinates are relative to a given origin.

IntSize

A two-dimensional size class used for measuring in Int pixels.

TextUnit

The unit used for text related dimension value.

Velocity

A two dimensional velocity in pixels per second.

Enums

LayoutDirection

A class for defining layout directions.

TextUnitType

An enum class defining for type of TextUnit.

Top-level functions summary

Constraints
Constraints(minWidth: Int = 0, maxWidth: Int = Constraints.Infinity, minHeight: Int = 0, maxHeight: Int = Constraints.Infinity)

Create a Constraints.

Density
Density(context: Context)

Creates a Density for this Context.

Density
Density(density: Float, fontScale: Float = 1f)

A density of the screen.

DpOffset
DpOffset(x: Dp, y: Dp)

Constructs a DpOffset from x and y position Dp values.

IntOffset
IntOffset(x: Int, y: Int)

Constructs a IntOffset from x and y position Int values.

IntRect
IntRect(offset: IntOffset, size: IntSize)

Construct a rectangle from its left and top edges as well as its width and height.

IntRect
IntRect(topLeft: IntOffset, bottomRight: IntOffset)

Construct the smallest rectangle that encloses the given offsets, treating them as vectors from the origin.

IntRect
IntRect(center: IntOffset, radius: Int)

Construct a rectangle that bounds the given circle

IntSize
IntSize(width: Int, height: Int)

Constructs an IntSize from width and height Int values.

Velocity
Velocity(x: Float, y: Float)

Constructs an Velocity from the given relative x and y velocities.

Dp
lerp(start: Dp, stop: Dp, fraction: Float)

Linearly interpolate between two Dps.

DpOffset
lerp(start: DpOffset, stop: DpOffset, fraction: Float)

Linearly interpolate between two DpOffsets.

IntOffset
lerp(start: IntOffset, stop: IntOffset, fraction: Float)

Linearly interpolate between two IntOffsets.

IntRect
lerp(start: IntRect, stop: IntRect, fraction: Float)

Linearly interpolate between two rectangles.

TextUnit
lerp(start: TextUnit, stop: TextUnit,