DpOffset


A two-dimensional offset using Dp for units.

To create a DpOffset, call the top-level function that accepts an x/y pair of coordinates:

val offset = DpOffset(x, y)

The primary constructor of DpOffset is intended to be used with the packedValue property to allow storing offsets in arrays or collections of primitives without boxing.

Summary

Nested types

Public companion properties

DpOffset

Represents an offset whose x and y are unspecified.

Cmn
DpOffset

A DpOffset with 0 DP x and 0 DP y values.

Cmn

Public constructors

DpOffset(packedValue: Long)
Cmn

Public functions

DpOffset
copy(x: Dp, y: Dp)

Returns a copy of this DpOffset instance optionally overriding the x or y parameter

Cmn
operator DpOffset
minus(other: DpOffset)

Subtract a DpOffset from another one.

Cmn
operator DpOffset
plus(other: DpOffset)

Add a DpOffset to another one.

Cmn
open String
Cmn

Public properties

Long

Long value encoding the x and y components of the DpOffset.

Cmn
Dp

The horizontal aspect of the offset in Dp

Cmn
Dp

The vertical aspect of the offset in Dp

Cmn

Extension functions

inline DpOffset

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

Cmn

Extension properties

Boolean

false when this is DpOffset.Unspecified.

Cmn
Boolean

true when this is DpOffset.Unspecified.

Cmn

Public companion properties

Unspecified

val UnspecifiedDpOffset

Represents an offset whose x and y are unspecified. This is usually a replacement for null when a primitive value is desired. Access to x or y on an unspecified offset is not allowed.

Zero

val ZeroDpOffset

A DpOffset with 0 DP x and 0 DP y values.

Public constructors

DpOffset

DpOffset(packedValue: Long)
Parameters
packedValue: Long

Long value encoding the x and y components of the DpOffset. Encoded values can be obtained by using the packedValue property of existing DpOffset instances.

Public functions

copy

fun copy(x: Dp = this.x, y: Dp = this.y): DpOffset

Returns a copy of this DpOffset instance optionally overriding the x or y parameter

minus

operator fun minus(other: DpOffset): DpOffset

Subtract a DpOffset from another one.

plus

operator fun plus(other: DpOffset): DpOffset

Add a DpOffset to another one.

toString

open fun toString(): String

Public properties

packedValue

val packedValueLong

Long value encoding the x and y components of the DpOffset. Encoded values can be obtained by using the packedValue property of existing DpOffset instances.

x

val xDp

The horizontal aspect of the offset in Dp

y

val yDp

The vertical aspect of the offset in Dp

Extension functions

takeOrElse

inline fun DpOffset.takeOrElse(block: () -> DpOffset): DpOffset

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

Extension properties

isSpecified

val DpOffset.isSpecifiedBoolean

false when this is DpOffset.Unspecified.

isUnspecified

val DpOffset.isUnspecifiedBoolean

true when this is DpOffset.Unspecified.