Google berkomitmen untuk mendorong terwujudnya keadilan ras bagi komunitas Kulit Hitam. Lihat caranya.

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).

DpCubed

Holds a unit of cubed dimensions, such as 1.value * 2.value * 3.dp.

DpInverse

Holds a unit of an inverse dimensions, such as 1.dp / (2.value * 3.dp).

DpSquared

Holds a unit of squared dimensions, such as 1.value * 2.dp.

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.

Position

A two-dimensional position using Dp for units

PxBounds

A four dimensional bounds using pixels for units

PxCubed

Holds a unit of cubed dimensions, such as 1.value * 2.value * 3.px.

PxInverse

Holds a unit of an inverse dimensions, such as 1.px / (2.value * 3.px).

PxSquared

Holds a unit of squared dimensions, such as 1.value * 2.px.

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 velocity in two dimensions.

Enums

LayoutDirection

A class for defining layout directions.

TextUnitType

An enum class defining for type of thextUnit.

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.

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.

Position
Position(x: Dp, y: Dp)

Constructs a Position from x and y position Dp values.

PxBounds
PxBounds(topLeft: Offset, size: Size)

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

Linearly interpolate between two Dps.

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

Linearly interpolate between two Positions.

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 DpInverse
Double.div(other: Dp)

operator Dp
Double.times(other: Dp)

operator TextUnit

Multiply a TextUnit by a scalar.

For kotlin.Float
operator DpInverse
Float.div(other: Dp)

operator Dp
Float.times(other: Dp)

operator TextUnit

Multiply a TextUnit by a scalar.

For kotlin.Int
operator DpInverse
Int.div(other: Dp)

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 Size
Offset

Returns the Offset of the center of the rect from the point of 0,0 with this Size.

PxBounds

Convert a Size to a PxBounds.

For PxBounds
Offset

Returns the Offset of the center of the PxBounds.

Rect

Convert a PxBounds to a Rect.

Size

Convert a PxBounds to a Size.

For Dp
Dp
Dp.coerceAtLeast(minimumValue: Dp)

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

Dp
Dp.coerceAtMost(maximumValue: Dp)

Ensures that this value is not greater than the specified maximumValue.

Dp
Dp.coerceIn(minimumValue: Dp, maximumValue: Dp)

Ensures that this value lies in the specified range minimumValue.

Boolean

Return true when it is finite or false when it is Dp.Infinity

For TextUnit
TextUnit

Ensures that the value of TextUnit is not less than the specified minimumValue.

TextUnit

Ensures that the value of TextUnit is not greater than the specified maximumValue.

TextUnit
TextUnit.coerceIn(minimumValue: TextUnit, maximumValue: TextUnit)

Ensures that the value of TextUnit lies in the specified range minimumValue.

For Constraints
IntSize

Takes a size and returns the closest size to it that satisfies the constraints.

Int

Takes a height and returns the closest size to it that satisfies the constraints.

Int

Takes a width and returns the closest size to it that satisfies the constraints.

Constraints
Constraints.enforce(otherConstraints: Constraints)

Returns the result of coercing the current constraints in a different set of constraints.

Constraints
Constraints.offset(horizontal: Int = 0, vertical: Int = 0)

Returns the Constraints obtained by offsetting the current instance with the given values.

Boolean

Takes a size and returns whether it satisfies the current constraints.

For Position
Dp

The magnitude of the offset represented by this Position.

For Duration
Long

Returns the number of whole days spanned by this Duration.

Long

Returns the number of whole hours spanned by this Duration.

Long

Returns number of whole microseconds spanned by this Duration.

Long

Returns number of whole milliseconds spanned by this Duration.

Long

Returns the number of whole minutes spanned by this Duration.

Long

Returns the number of whole seconds spanned by this Duration.

operator Uptime
Duration.plus(uptime: Uptime)

Add a Duration to a Uptime and returns the result as a Uptime.

For Offset
operator Offset

operator Offset

IntOffset

Round a Offset down to the nearest Int coordinates.

For IntOffset
operator Offset

operator Offset

Offset

Converts the IntOffset to an Offset.

For Velocity
operator Velocity

Return the difference of two velocities.

operator Velocity

Return the sum of two velocities.

For IntSize
IntBounds

Convert an IntSize to an IntBounds.

Size

Extension properties summary

For kotlin.Double
Dp

Create a Dp using a Double: val left = 10.

TextUnit

Creates an EM unit TextUnit

TextUnit

Creates a SP unit TextUnit

For kotlin.Float
Dp

Create a Dp using a Float: val left = 10f val x = left.

TextUnit

Creates an EM unit TextUnit

TextUnit

Creates a SP unit TextUnit

For kotlin.Int
Duration

Dp

Create a Dp using an Int: val left = 10 val x = left.

TextUnit

Creates an EM unit TextUnit

Duration

Duration

Duration

Duration

Duration

Duration

TextUnit

Creates a SP unit TextUnit

For kotlin.Long
Duration

Duration

Duration

Duration

Duration

Duration

Duration

For IntSize
IntOffset

Returns the IntOffset of the center of the rect from the point of 0,0 with this IntSize.

For Constraints
Boolean

Whether there is exactly one height value that satisfies the constraints.

Boolean

Whether there is exactly one width value that satisfies the constraints.

Boolean

Whether the area of a component respecting these constraints will definitely be 0.

For Bounds
Dp

A height of this Bounds in Dp.

Dp

A width of this Bounds in Dp.

For IntBounds
Int

The height of this IntBounds in integer pixels.

Int

The width of this IntBounds in integer pixels.

For PxBounds
Float

A height of this PxBounds in pixels.

Float