The second Android 11 Developer Preview is now available, test it out and share your feedback.

androidx.ui.unit

Classes

Bounds

A four dimensional bounds using Dp for units

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.

IntPx

Dimension value represented in whole pixels (px).

IntPxBounds

A four dimensional bounds using IntPx for units

IntPxPosition

A two-dimensional position using IntPx for units

IntPxSize

A two dimensional size using IntPx for units

Position

A two-dimensional position using Dp for units

Px

Dimension value represented in pixels (px).

PxBounds

A four dimensional bounds using Px 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).

PxPosition

A two-dimensional position using Px for units

PxSize

A two dimensional size using Px for units

PxSquared

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

Size

A two dimensional size using Dp for units

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

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

Top-level functions summary

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.

IntPxPosition

Constructs a IntPxPosition from x and y position IntPx values.

IntPxSize
IntPxSize(width: IntPx, height: IntPx)

Constructs an IntPxSize from width and height IntPx values.

Position
Position(x: Dp, y: Dp)

Constructs a Position from x and y position Dp values.

PxBounds
PxBounds(topLeft: PxPosition, size: PxSize)

PxPosition

Create a PxPosition from IntPx values.

PxPosition
PxPosition(x: Px, y: Px)

Constructs a PxPosition from x and y position Px values.

PxSize
PxSize(width: IntPx, height: IntPx)

Create a PxSize from IntPx values.

PxSize
PxSize(width: Px, height: Px)

Constructs a PxSize from width and height Px values.

Size
Size(width: Dp, height: Dp)

Constructs a Size from width and height Dp values.

Px
abs(x: Px)

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.

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

Linearly interpolate between two IntPxs.

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

Linearly interpolate between two IntPxPositions.

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

Linearly interpolate between two Pxs.

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

Linearly interpolate between two PxPositions.

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

Dp
max(a: Dp, b: Dp)

IntPx
max(a: IntPx, b: IntPx)

Return the maximum of two IntPxs.

Px
max(a: Px, b: Px)

TextUnit

Returns the smaller value from the given values.

Dp
min(a: Dp, b: Dp)

IntPx
min(a: IntPx, b: IntPx)

Return the minimum of two IntPxs.

Px
min(a: Px, b: Px)

TextUnit

Returns the smaller value from the given values.

Top-level properties summary

Long

Long

Long

Long

Long

Extension functions summary

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

operator PxInverse
Double.div(other: Px)

operator Dp
Double.times(other: Dp)

operator Size
Double.times(size: Size)

Returns a Size with size's Size.width and Size.height multiplied by this

operator IntPx
Double.times(other: IntPx)

Multiply an IntPx by a Double and round the result to an IntPx.

operator Px
Double.times(other: Px)

operator PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

operator TextUnit

Multiply a TextUnit by a scalar.

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

operator PxInverse
Float.div(other: Px)

operator Dp
Float.times(other: Dp)

operator Size
Float.times(size: Size)

Returns a Size with size's Size.width and Size.height multiplied by this

operator IntPx
Float.times(other: IntPx)

Multiply an IntPx by a Float and round the result to an IntPx.

operator Px
Float.times(other: Px)

operator PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

operator TextUnit

Multiply a TextUnit by a scalar.

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

operator PxInverse
Int.div(other: Px)

operator Dp
Int.times(other: Dp)

operator Size
Int.times(size: Size)

Returns a Size with size's Size.width and Size.height multiplied by this

operator IntPx
Int.times(other: IntPx)

Multiply an IntPx by a Double to result in an IntPx.

operator IntPxSize

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

operator Px
Int.times(other: Px)

operator PxSize
Int.times(size: PxSize)

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

operator TextUnit
Int.times(other: TextUnit)

Multiply a TextUnit by a scalar.

For Px
IntPx

Rounds up a Px to the smallest integer value that is not less than the original value.

Px
Px.coerceAtLeast(minimumValue: Px)

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

Px
Px.coerceAtMost(maximumValue: Px)

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

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

Ensures that this value lies in the specified range minimumValue.

IntPx

Rounds a Px size to the nearest Int pixel value.

For Size
Position

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

Bounds

Convert a Size to a Bounds.

For IntPxSize
IntPxPosition

Returns the IntPxPosition of the center of the rect from the point of 0,0 with this IntPxSize.

PxSize

Convert a IntPxSize to a PxSize

For PxSize
PxPosition

Returns the PxPosition of the center of the rect from the point of 0,0 with this PxSize.

PxBounds

Convert a PxSize to a PxBounds.

Rect

Convert a PxSize to a Rect.

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 IntPx
IntPx
IntPx.coerceAtLeast(minimumValue: IntPx)

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

IntPx
IntPx.coerceAtMost(maximumValue: IntPx)

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

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

Ensures that this value lies in the specified range minimumValue.

Boolean

Return whether true when it is finite or false when it is IntPx.Infinity

Px

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 Position
Dp

The magnitude of the offset represented by this Position.

For PxPosition
Px

The magnitude of the offset represented by this PxPosition.

IntPxPosition

Round a PxPosition down to the nearest Int coordinates.

Offset

Convert a PxPosition to a Offset.

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 Velocity
operator Velocity

Return the difference of two velocities.

operator Velocity

Return the sum of two velocities.

For IntPxPosition
PxPosition

Convert a IntPxPosition to a PxPosition

For PxBounds
Rect

Convert a PxBounds to a Rect.

PxSize

Convert a PxBounds to a PxSize.

For Bounds
Size

Convert a Bounds to a Size.

For IntPxBounds
IntPxSize

Convert a IntPxBounds to a IntPxSize.

Extension properties summary

For kotlin.Double
Dp

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

TextUnit

Creates an EM unit TextUnit

Px

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

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

Px

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

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

IntPx

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

Duration

Duration

Duration

Duration

Px

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

Duration

TextUnit

Creates a SP unit TextUnit

For kotlin.Long
Duration

Duration

Duration

Duration

Duration

Duration

Duration

For Bounds
Dp

A height of this Bounds in Dp.

Dp

A width of this Bounds in Dp.

For IntPxBounds
IntPx

A height of this IntPxBounds in IntPx.

IntPx

A width of this IntPxBounds in IntPx.

For PxBounds
Px

A height of this PxBounds in Px.

Px

A width of this PxBounds in Px.

For PxSize
Px

Returns the smallest dimension size.

Top-level constants

HoursPerDay

const val HoursPerDay: Long
Value: 24L

MicrosecondsPerMillisecond

const val MicrosecondsPerMillisecond: Long
Value: 1000L

MillisecondsPerSecond

const val MillisecondsPerSecond: Long
Value: 1000L

MinutesPerHour

const val MinutesPerHour: Long
Value: 60L

NanosecondsPerMicrosecond

const val NanosecondsPerMicrosecond: Long
Value: 1000L

SecondsPerMinute

const val SecondsPerMinute: Long
Value: 60L

Top-level functions

Density

fun Density(context: Context): Density

Creates a Density for this Context.

Parameters
context: Context density values will be extracted from this Context

Density

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

A density of the screen. Used for convert Dp to pixels.

Parameters
density: Float The logical density of the display. This is a scaling factor for the Dp unit.
fontScale: Float = 1f Current user preference for the scaling factor for fonts.

Duration

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

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

IntPxPosition

inline fun IntPxPosition(
    x: IntPx,
    y: IntPx
): IntPxPosition

Constructs a IntPxPosition from x and y position IntPx values.

IntPxSize

inline fun IntPxSize(
    width: IntPx,
    height: IntPx
): IntPxSize

Constructs an IntPxSize from width and height IntPx values.

Position

inline fun Position(
    x: Dp,
    y: Dp
): Position

Constructs a Position from x and y position Dp values.

PxBounds

inline fun PxBounds(
    topLeft: PxPosition,
    size: PxSize
): PxBounds

PxPosition

inline fun PxPosition(
    x: IntPx,
    y: IntPx
): PxPosition

Create a PxPosition from IntPx values.

PxPosition

inline fun PxPosition(
    x: Px,
    y: Px
): PxPosition

Constructs a PxPosition from x and y position Px values.

PxSize

inline fun PxSize(
    width: IntPx,
    height: IntPx
): PxSize

Create a PxSize from IntPx values.

PxSize

inline fun PxSize(
    width: Px,
    height: Px
): PxSize

Constructs a PxSize from width and height Px values.

Size

inline fun Size(
    width: Dp,
    height: Dp
): Size

Constructs a Size from width and height Dp values.

abs

inline fun abs(x: Px): Px

lerp

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

Linearly interpolate between two Dps.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

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

Linearly interpolate between two Positions.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

fun lerp(
    start: IntPx,
    stop: IntPx,
    fraction: Float
): IntPx

Linearly interpolate between two IntPxs.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

If start or stop is IntPx.Infinity, then IntPx.Infinity is returned.

lerp

fun lerp(
    start: IntPxPosition,
    stop: IntPxPosition,
    fraction: Float
): IntPxPosition

Linearly interpolate between two IntPxPositions.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

fun lerp(
    start: Px,
    stop: Px,
    fraction: Float
): Px

Linearly interpolate between two Pxs.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

fun lerp(
    start: PxPosition,
    stop: PxPosition,
    fraction: Float
): PxPosition

Linearly interpolate between two PxPositions.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

lerp

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

max

inline fun max(
    a: Dp,
    b: Dp
): Dp

max

inline fun max(
    a: IntPx,
    b: IntPx
): IntPx

Return the maximum of two IntPxs. An IntPx.Infinity is considered the maximum value.

max

inline fun max(
    a: Px,
    b: Px
): Px

max

inline fun max(
    a: TextUnit,
    b: TextUnit
): TextUnit

Returns the smaller value from the given values.

This operation works only if all the operands are the same unit type and they are not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

min

inline fun min(
    a: Dp,
    b: Dp
): Dp

min

inline fun min(
    a: IntPx,
    b: IntPx
): IntPx

Return the minimum of two IntPxs. Any value is considered less than IntPx.Infinity.

min

inline fun min(
    a: Px,
    b: Px
): Px

min

inline fun min(
    a: TextUnit,
    b: TextUnit
): TextUnit

Returns the smaller value from the given values.

This operation works only if all the operands are the same unit type and they are not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

Top-level properties

NanosecondsPerDay

val NanosecondsPerDay: Long

NanosecondsPerHour

val NanosecondsPerHour: Long

NanosecondsPerMillisecond

val NanosecondsPerMillisecond: Long

NanosecondsPerMinute

val NanosecondsPerMinute: Long

NanosecondsPerSecond

val NanosecondsPerSecond: Long

Extension functions

ceil

inline fun Px.ceil(): IntPx

Rounds up a Px to the smallest integer value that is not less than the original value.

center

fun Size.center(): Position

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

center

fun IntPxSize.center(): IntPxPosition

Returns the IntPxPosition of the center of the rect from the point of 0,0 with this IntPxSize.

center

fun PxSize.center(): PxPosition

Returns the PxPosition of the center of the rect from the point of 0,0 with this PxSize.

coerceAtLeast

inline fun Px.coerceAtLeast(minimumValue: Px): Px

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

Return
this value if it 's greater than or equal to the minimumValue or the minimumValue otherwise.

coerceAtLeast

inline fun Dp.coerceAtLeast(minimumValue: Dp): Dp

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

Return
this value if it 's greater than or equal to the minimumValue or the minimumValue otherwise.

coerceAtLeast

inline fun IntPx.coerceAtLeast(minimumValue: IntPx): IntPx

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

Return
this value if it 's greater than or equal to the minimumValue or the minimumValue otherwise.

coerceAtLeast

inline fun TextUnit.coerceAtLeast(minimumValue: TextUnit): TextUnit

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

Return
this value if it 's greater than or equal to the minimumValue or the minimumValue otherwise.

coerceAtMost

inline fun Px.coerceAtMost(maximumValue: Px): Px

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

Return
this value if it 's less than or equal to the maximumValue or the maximumValue otherwise.

coerceAtMost

inline fun Dp.coerceAtMost(maximumValue: Dp): Dp

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

Return
this value if it 's less than or equal to the maximumValue or the maximumValue otherwise.

coerceAtMost

inline fun IntPx.coerceAtMost(maximumValue: IntPx): IntPx

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

Return
this value if it 's less than or equal to the maximumValue or the maximumValue otherwise. Passing IntPx.Infinity as maximumValue will always return this.

coerceAtMost

inline fun TextUnit.coerceAtMost(maximumValue: TextUnit): TextUnit

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

Return
this value if it 's less than or equal to the maximumValue or the maximumValue otherwise.

coerceIn

inline fun Px.coerceIn(
    minimumValue: Px,
    maximumValue: Px
): Px

Ensures that this value lies in the specified range minimumValue..maximumValue.

Return
this value if it 's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

coerceIn

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

Ensures that this value lies in the specified range minimumValue..maximumValue.

Return
this value if it 's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

coerceIn

inline fun IntPx.coerceIn(
    minimumValue: IntPx,
    maximumValue: IntPx
): IntPx

Ensures that this value lies in the specified range minimumValue..maximumValue.

Return
this value if it 's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

coerceIn

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

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

This operation works only if all the operands are the same unit type and they are not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

Return
this value if it 's in the range, or minimumValue if this value is less than minimumValue, or maximumValue if this value is greater than maximumValue.

div

inline operator fun Double.div(other: Dp): DpInverse

div

inline operator fun Double.div(other: Px): PxInverse

div

inline operator fun Float.div(other: Dp): DpInverse

div

inline operator fun Float.div(other: Px): PxInverse

div

inline operator fun Int.div(other: Dp): DpInverse

div

inline operator fun Int.div(other: Px): PxInverse

getDistance

fun Position.getDistance(): Dp

The magnitude of the offset represented by this Position.

getDistance

fun PxPosition.getDistance(): Px

The magnitude of the offset represented by this PxPosition.

inDays

fun Duration.inDays(): Long

Returns the number of whole days spanned by this Duration.

inHours

fun Duration.inHours(): Long

Returns the number of whole hours spanned by this Duration.

The returned value can be greater than 23.

inMicroseconds

fun Duration.inMicroseconds(): Long

Returns number of whole microseconds spanned by this Duration.

inMilliseconds

fun Duration.inMilliseconds(): Long

Returns number of whole milliseconds spanned by this Duration.

The returned value can be greater than 999.

inMinutes

fun Duration.inMinutes(): Long

Returns the number of whole minutes spanned by this Duration.

The returned value can be greater than 59.

inSeconds

fun Duration.inSeconds(): Long

Returns the number of whole seconds spanned by this Duration.

The returned value can be greater than 59.

isFinite

inline fun Dp.isFinite(): Boolean

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

isFinite

inline fun IntPx.isFinite(): Boolean

Return whether true when it is finite or false when it is IntPx.Infinity

minus

operator fun Velocity.minus(other: Velocity): Velocity

Return the difference of two velocities.

plus

operator fun Duration.plus(uptime: Uptime): Uptime

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

plus

operator fun Velocity.plus(other: Velocity): Velocity

Return the sum of two velocities.

round

inline fun Px.round(): IntPx

Rounds a Px size to the nearest Int pixel value.

round

inline fun PxPosition.round(): IntPxPosition

Round a PxPosition down to the nearest Int coordinates.

times

inline operator fun Double.times(other: Dp): Dp

times

inline operator fun Double.times(size: Size): Size

Returns a Size with size's Size.width and Size.height multiplied by this

times

inline operator fun Double.times(other: IntPx): IntPx

Multiply an IntPx by a Double and round the result to an IntPx. Any operation on an IntPx.Infinity results in IntPx.Infinity

times

inline operator fun Double.times(other: Px): Px

times

inline operator fun Double.times(size: PxSize): PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

times

inline operator fun Double.times(other: TextUnit): TextUnit

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

times

inline operator fun Float.times(other: Dp): Dp

times

inline operator fun Float.times(size: Size): Size

Returns a Size with size's Size.width and Size.height multiplied by this

times

inline operator fun Float.times(other: IntPx): IntPx

Multiply an IntPx by a Float and round the result to an IntPx. Any operation on an IntPx.Infinity results in IntPx.Infinity

times

inline operator fun Float.times(other: Px): Px

times

inline operator fun Float.times(size: PxSize): PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

times

inline operator fun Float.times(other: TextUnit): TextUnit

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

times

inline operator fun Int.times(other: Dp): Dp

times

inline operator fun Int.times(size: Size): Size

Returns a Size with size's Size.width and Size.height multiplied by this

times

inline operator fun Int.times(other: IntPx): IntPx

Multiply an IntPx by a Double to result in an IntPx. Any operation on an IntPx.Infinity results in IntPx.Infinity

times

inline operator fun Int.times(size: IntPxSize): IntPxSize

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

times

inline operator fun Int.times(other: Px): Px

times

inline operator fun Int.times(size: PxSize): PxSize

Returns a PxSize with size's PxSize.width and PxSize.height multiplied by this

times

inline operator fun Int.times(other: TextUnit): TextUnit

Multiply a TextUnit by a scalar.

This operation works only if the right operand is not equal to TextUnit.Inherit. The result of this operation is the same unit type of the given one.

toBounds

fun Size.toBounds(): Bounds

Convert a Size to a Bounds.

toBounds

fun PxSize.toBounds(): PxBounds

Convert a PxSize to a PxBounds. The left and top are 0.px and the right and bottom are the width and height, respectively.

toOffset

inline fun PxPosition.toOffset(): Offset

Convert a PxPosition to a Offset.

toPx

inline fun IntPx.toPx(): Px

toPxPosition

inline fun IntPxPosition.toPxPosition(): PxPosition

Convert a IntPxPosition to a PxPosition

toPxSize

inline fun IntPxSize.toPxSize(): PxSize

Convert a IntPxSize to a PxSize

toRect

fun PxSize.toRect(): Rect

Convert a PxSize to a Rect.

toRect

fun PxBounds.toRect(): Rect

Convert a PxBounds to a Rect.

toSize

fun PxBounds.toSize(): PxSize

Convert a PxBounds to a PxSize.

toSize

inline fun Bounds.toSize(): Size

Convert a Bounds to a Size.

toSize

inline fun IntPxBounds.toSize(): IntPxSize

Convert a IntPxBounds to a IntPxSize.

Extension properties

days

val Int.days: Duration

days

val Long.days: Duration

dp

inline val Double.dp: Dp

Create a Dp using a Double: val left = 10.0 val x = left.dp // -- or -- val y = 10.0.dp

dp

inline val Float.dp: Dp

Create a Dp using a Float: val left = 10f val x = left.dp // -- or -- val y = 10f.dp

dp

inline val Int.dp: Dp

Create a Dp using an Int: val left = 10 val x = left.dp // -- or -- val y = 10.dp

em

val Double.em: TextUnit

Creates an EM unit TextUnit

em

val Float.em: TextUnit

Creates an EM unit TextUnit

em

val Int.em: TextUnit

Creates an EM unit TextUnit

height

inline val Bounds.height: Dp

A height of this Bounds in Dp.

height

inline val IntPxBounds.height: IntPx

A height of this IntPxBounds in IntPx.

height

inline val PxBounds.height: Px

A height of this PxBounds in Px.

hours

val Int.hours: Duration

hours

val Long.hours: Duration

ipx

inline val Int.ipx: IntPx

Create a IntPx using an Int: val left = 10 val x = left.ipx // -- or -- val y = 10.ipx

microseconds

val Int.microseconds: Duration

microseconds

val Long.microseconds: Duration

milliseconds

val Int.milliseconds: Duration

milliseconds

val Long.milliseconds: Duration

minDimension

val PxSize.minDimension: Px

Returns the smallest dimension size.

minutes

val Int.minutes: Duration

minutes

val Long.minutes: Duration

nanoseconds

val Int.nanoseconds: Duration

nanoseconds

val Long.nanoseconds: Duration

px

inline val Double.px: Px

Create a Px using a Double: val left = 10.0 val x = left.px // -- or -- val y = 10.0.px

px

inline val Float.px: Px

Create a Px using a Float: val left = 10f val x = left.px // -- or -- val y = 10f.px

px

inline val Int.px: Px

Create a Px using an Int: val left = 10 val x = left.px // -- or -- val y = 10.px

seconds

val Int.seconds: Duration

seconds

val Long.seconds: Duration

sp

val Double.sp: TextUnit

Creates a SP unit TextUnit

sp

val Float.sp: TextUnit

Creates a SP unit TextUnit

sp

val Int.sp: TextUnit

Creates a SP unit TextUnit

width

inline val Bounds.width: Dp

A width of this Bounds in Dp.

width

inline val IntPxBounds.width: IntPx

A width of this IntPxBounds in IntPx.

width

inline val PxBounds.width: Px

A width of this PxBounds in Px.