androidx.compose.ui.unit
DpOffset
Value class · from org.jetbrains.compose.ui:ui-unit:1.12.2
No hand-written docs yet.
A two-dimensional offset using Dp for units.
value class DpOffset(
packedValue: Long,
)
How to get one
Create it
Ready-made values and functions that return it
Used by
Parameters that take a DpOffset.
DpOffset.minus(other)DpOffset.plus(other)DropdownMenu(offset)DropdownMenuPopup(offset)MenuDefaults.rememberDropdownMenuPopupPositionProvider(offset)
Properties
x
val x: Dp
The horizontal aspect of the offset in Dp
y
val y: Dp
The vertical aspect of the offset in Dp
Zero
val Zero: DpOffset
A DpOffset with 0 DP x and 0 DP y values.
Unspecified
val Unspecified: DpOffset
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.
packedValue
val packedValue: Long
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
fun minus(other: DpOffset): DpOffset
Subtract a DpOffset from another one.
plus
fun plus(other: DpOffset): DpOffset
Add a DpOffset to another one.
Library docs
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.