Google is committed to advancing racial equity for Black communities. See how.

androidx.compose.ui.unit

Interfaces

Density

A density of the screen.

Classes

Bounds

A four dimensional bounds using Dp for units

Constraints

Immutable constraints used for measuring child Layouts or LayoutModifiers.

Dp

Dimension value representing device-independent pixels (dp).

DpOffset

A two-dimensional offset using Dp for units

Duration

A span of time, such as 27 days, 4 hours, 12 minutes, and 3 seconds.

IntBounds

A four dimensional bounds holder defined by integer pixels.

IntOffset

A two-dimensional position using Int pixels for units

IntSize

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

TextUnit

The unit used for text related dimension value.

Uptime

A single point in time with a time base of the system's uptime nanoseconds.

Velocity

A two dimensional velocity in pixels per second.

Type-aliases

Position

Enums

LayoutDirection

A class for defining layout directions.

TextUnitType

An enum class defining for type of TextUnit.

Top-level constants summary

const Long

const Long

const Long

const Long

const Long

const Long

const Long

const Long

const Long

const Long

const Long

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.

Duration
Duration(days: Long = 0, hours: Long = 0, minutes: Long = 0, seconds: Long = 0, milliseconds: Long = 0, microseconds: Long = 0, nanoseconds: Long = 0)

Constructs a Duration given a series of time intervals in different units.

IntBounds
IntBounds(topLeft: IntOffset, size: IntSize)

IntOffset
IntOffset(x: Int, y: Int)

Constructs a IntOffset from x and y position Int values.

IntSize
IntSize(width: Int, height: Int)

Constructs an IntSize from width and height Int values.

DpOffset
Position(x: Dp, y: Dp)

Velocity
Velocity(offset: Offset)

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.

TextUnit
lerp(a: TextUnit, b: TextUnit, t: Float)

Dp
max(a: Dp, b: Dp)

TextUnit

Returns the smaller value from the given values.

Dp
min(a: Dp, b: Dp)

TextUnit

Returns the smaller value from the given values.

Extension functions summary

For kotlin.Double
operator Dp
Double.times(other: Dp)

operator TextUnit

Multiply a TextUnit by a scalar.

For kotlin.Float
operator Dp
Float.times(other: Dp)

operator TextUnit

Multiply a TextUnit by a scalar.

For kotlin.Int
operator Dp
Int.times(other: Dp)

operator IntSize
Int.times(size: IntSize)

Returns an IntSize with size's IntSize.width and IntSize.height multiplied by this.

operator TextUnit
Int.times(other: TextUnit)

Multiply a TextUnit by a scalar.

For IntBounds
IntOffset

Returns the IntOffset of the center of the IntBounds.

Rect

Convert an IntBounds to a Rect.

IntSize

Convert an IntBounds to an IntSize.

For Dp
Dp
Dp.coerceAtLeast(minimumValue: Dp)

Ensures that this value is not less than the specified minimumValue.

Dp
Dp.coerceAtMost(maximumValue