Start native apps faster with the Composables CLI ->

Dimension value representing device-independent pixels (dp).

Source set: Common
public class Dp public constructor(public val value: Float) : Comparable<Dp>

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.

Drawing and Layout are done in pixels. To retrieve the pixel size of a Dp, use Density.toPx:

Functions

plus

Source set: Common
@Stable public inline operator fun plus(other: Dp): Dp

Add two Dps together.

minus

Source set: Common
@Stable public inline operator fun minus(other: Dp): Dp

Subtract a Dp from another one.

unaryMinus

Source set: Common
@Stable public inline operator fun unaryMinus(): Dp

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

div

Source set: Common
@Stable public inline operator fun div(other: Float): Dp

Divide a Dp by a scalar.

div

Source set: Common
@Stable public inline operator fun div(other: Int): Dp

div

Source set: Common
@Stable public inline operator fun div(other: Dp): Float

Divide by another Dp to get a scalar.

times

Source set: Common
@Stable public inline operator fun times(other: Float): Dp

Multiply a Dp by a scalar.

times

Source set: Common
@Stable public inline operator fun times(other: Int): Dp

Members

Companion

Source set: Common
public companion object

Properties

Hairline

Source set: Common
public 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

Source set: Common
public val Infinity: Dp

Infinite dp dimension.

Unspecified

Source set: Common
public val Unspecified: Dp

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