androidx.compose.ui.unit

Dp

Value class · from org.jetbrains.compose.ui:ui-unit:1.12.2

No hand-written docs yet.

Dimension value representing device-independent pixels (dp). Component APIs specify their dimensions such as line thickness in DP with Dp objects. Hairline (1 pixel) thickness may be specified with Hairline, a dimension that take up no space. Dp are normally defined using dp, which can be applied to Int, Double, and Float.

value class Dp(
    value: Float,
) : Comparable<Dp>

Is a

How to get one

Create it

Ready-made values and functions that return it

23 more

Used by

Parameters that take a Dp.

150 more

Properties

Hairline

val Hairline: Dp

A dimension used to represent a hairline drawing element. Hairline elements take up no space, but will draw a single pixel, independent of the device's resolution and density.

Infinity

val Infinity: Dp

Infinite dp dimension.

Unspecified

val Unspecified: Dp

Constant that means unspecified Dp. Instead of comparing a Dp value to this constant, consider using isSpecified and isUnspecified instead.

value

val value: Float

Functions

plus

fun plus(other: Dp): Dp

Add two Dps together.

minus

fun minus(other: Dp): Dp

Subtract a Dp from another one.

unaryMinus

fun unaryMinus(): Dp

This is the same as multiplying the Dp by -1.0.

div

fun div(other: Float): Dp

Divide a Dp by a scalar.

fun div(other: Int): Dp
fun div(other: Dp): Float

Divide by another Dp to get a scalar.

times

fun times(other: Float): Dp

Multiply a Dp by a scalar.

fun times(other: Int): Dp
Library docs

Dimension value representing device-independent pixels (dp). Component APIs specify their dimensions such as line thickness in DP with Dp objects. Hairline (1 pixel) thickness may be specified with Hairline, a dimension that take up no space. Dp are normally defined using dp, which can be applied to Int, Double, and Float.