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

DpKt

public final class DpKt


Summary

Public methods

static final @NonNull DpOffset

Constructs a DpOffset from x and y position Dp values.

static final @NonNull DpSize
DpSize(@NonNull Dp width, @NonNull Dp height)

Constructs a DpSize from width and height values.

static final @NonNull Dp
coerceAtLeast(@NonNull Dp receiver, @NonNull Dp minimumValue)

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

static final @NonNull Dp
coerceAtMost(@NonNull Dp receiver, @NonNull Dp maximumValue)

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

static final @NonNull Dp
coerceIn(
    @NonNull Dp receiver,
    @NonNull Dp minimumValue,
    @NonNull Dp maximumValue
)

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

static final @NonNull DpOffset

Returns the DpOffset of the center of the rect from the point of 0, 0 with this DpSize.

static final @NonNull Dp
getDp(double receiver)

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

static final @NonNull Dp
getDp(float receiver)

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

static final @NonNull Dp
getDp(int receiver)

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

static final @NonNull Dp

A height of this Bounds in Dp.

static final @NonNull DpSize
getSize(@NonNull DpRect receiver)

Returns the size of the DpRect.

static final @NonNull Dp
getWidth(@NonNull DpRect receiver)

A width of this Bounds in Dp.

static final boolean
isFinite(@NonNull Dp receiver)

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

static final boolean
isSpecified(@NonNull Dp receiver)

false when this is Dp.Unspecified.

static final boolean

false when this is DpOffset.Unspecified.

static final boolean

false when this is DpSize.Unspecified.

static final boolean

true when this is Dp.Unspecified.

static final boolean

true when this is DpOffset.Unspecified.

static final boolean

true when this is DpSize.Unspecified.

static final @NonNull Dp
lerp(@NonNull Dp start, @NonNull Dp stop, float fraction)

Linearly interpolate between two Dps.

static final @NonNull DpOffset
lerp(@NonNull DpOffset start, @NonNull DpOffset stop, float fraction)

Linearly interpolate between two DpOffsets.

static final @NonNull DpSize
lerp(@NonNull DpSize start, @NonNull DpSize stop, float fraction)

Linearly interpolate between two DpSizes.

static final @NonNull Dp
max(@NonNull Dp a, @NonNull Dp b)
static final @NonNull Dp
min(@NonNull Dp a, @NonNull Dp b)
static final @NonNull Dp
takeOrElse(@NonNull Dp receiver, @NonNull Function0<@NonNull Dp> block)

If this Dp then this is returned, otherwise block is executed and its result is returned.

static final @NonNull DpOffset
takeOrElse(
    @NonNull DpOffset receiver,
    @NonNull Function0<@NonNull DpOffset> block
)

If this DpOffset isSpecified then this is returned, otherwise block is executed and its result is returned.

static final @NonNull DpSize
takeOrElse(
    @NonNull DpSize receiver,
    @NonNull Function0<@NonNull DpSize> block
)

If this DpSize isSpecified then this is returned, otherwise block is executed and its result is returned.

static final @NonNull Dp
times(double receiver, @NonNull Dp other)
static final @NonNull Dp
times(float receiver, @NonNull Dp other)
static final @NonNull DpSize
times(float receiver, @NonNull DpSize size)
static final @NonNull Dp
times(int receiver, @NonNull Dp other)
static final @NonNull DpSize
times(int receiver, @NonNull DpSize size)

Public methods

DpOffset

public static final @NonNull DpOffset DpOffset(@NonNull Dp x, @NonNull Dp y)

Constructs a DpOffset from x and y position Dp values.

DpSize

public static final @NonNull DpSize DpSize(@NonNull Dp width, @NonNull Dp height)

Constructs a DpSize from width and height values.

coerceAtLeast

public static final @NonNull Dp coerceAtLeast(@NonNull Dp receiver, @NonNull Dp minimumValue)

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

Returns
@NonNull Dp

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

coerceAtMost

public static final @NonNull Dp coerceAtMost(@NonNull Dp receiver, @NonNull Dp maximumValue)

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

Returns
@NonNull Dp

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

coerceIn

public static final @NonNull Dp coerceIn(
    @NonNull Dp receiver,
    @NonNull Dp minimumValue,
    @NonNull Dp maximumValue
)

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

Returns
@NonNull Dp

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.

getCenter

public static final @NonNull DpOffset getCenter(@NonNull DpSize receiver)

Returns the DpOffset of the center of the rect from the point of 0, 0 with this DpSize.

getDp

public static final @NonNull Dp getDp(double receiver)

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

getDp

public static final @NonNull Dp getDp(float receiver)

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

getDp

public static final @NonNull Dp getDp(int receiver)

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

getHeight

public static final @NonNull Dp getHeight(@NonNull DpRect receiver)

A height of this Bounds in Dp.

getSize

public static final @NonNull DpSize getSize(@NonNull DpRect receiver)

Returns the size of the DpRect.

getWidth

public static final @NonNull Dp getWidth(@NonNull DpRect receiver)

A width of this Bounds in Dp.

isFinite

public static final boolean isFinite(@NonNull Dp receiver)

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

isSpecified

public static final boolean isSpecified(@NonNull Dp receiver)

false when this is Dp.Unspecified.

isSpecified

public static final boolean isSpecified(@NonNull DpOffset receiver)

false when this is DpOffset.Unspecified.

isSpecified

public static final boolean isSpecified(@NonNull DpSize receiver)

false when this is DpSize.Unspecified.

isUnspecified

public static final boolean isUnspecified(@NonNull Dp receiver)

true when this is Dp.Unspecified.

isUnspecified

public static final boolean isUnspecified(@NonNull DpOffset receiver)

true when this is DpOffset.Unspecified.

isUnspecified

public static final boolean isUnspecified(@NonNull DpSize receiver)

true when this is DpSize.Unspecified.

lerp

public static final @NonNull Dp lerp(@NonNull Dp start, @NonNull Dp stop, float fraction)

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

public static final @NonNull DpOffset lerp(@NonNull DpOffset start, @NonNull DpOffset stop, float fraction)

Linearly interpolate between two DpOffsets.

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

public static final @NonNull DpSize lerp(@NonNull DpSize start, @NonNull DpSize stop, float fraction)

Linearly interpolate between two DpSizes.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start, 1.0 meaning that the interpolation has finished, returning 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.

max

public static final @NonNull Dp max(@NonNull Dp a, @NonNull Dp b)

min

public static final @NonNull Dp min(@NonNull Dp a, @NonNull Dp b)

takeOrElse

public static final @NonNull Dp takeOrElse(@NonNull Dp receiver, @NonNull Function0<@NonNull Dp> block)

If this Dp then this is returned, otherwise block is executed and its result is returned.

takeOrElse

public static final @NonNull DpOffset takeOrElse(
    @NonNull DpOffset receiver,
    @NonNull Function0<@NonNull DpOffset> block
)

If this DpOffset isSpecified then this is returned, otherwise block is executed and its result is returned.

takeOrElse

public static final @NonNull DpSize takeOrElse(
    @NonNull DpSize receiver,
    @NonNull Function0<@NonNull DpSize> block
)

If this DpSize isSpecified then this is returned, otherwise block is executed and its result is returned.

times

public static final @NonNull Dp times(double receiver, @NonNull Dp other)

times

public static final @NonNull Dp times(float receiver, @NonNull Dp other)

times

public static final @NonNull DpSize times(float receiver, @NonNull DpSize size)

times

public static final @NonNull Dp times(int receiver, @NonNull Dp other)

times

public static final @NonNull DpSize times(int receiver, @NonNull DpSize size)