Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

Dp

@Immutable inline class Dp : Comparable<Dp>
kotlin.Any
   ↳ androidx.compose.ui.unit.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. val leftMargin = 10.dp val rightMargin = 10f.dp val topMargin = 20.0.dp val bottomMargin = 10.dp Drawing is done in pixels. To retrieve the pixel size of a Dp, use toPx: val lineThicknessPx = lineThickness.toPx(context) toPx is normally needed only for painting operations.

Summary

Public constructors
<init>(value: Float)

Dimension value representing device-independent pixels (dp).

Public methods
operator Int
compareTo(other: Dp)

Support comparing Dimensions with comparison operators.

operator Dp
div(other: Float)

Divide a Dp by a scalar.

operator Dp
div(other: Int)

operator Float
div(other: Dp)

Divide by another Dp to get a scalar.

operator Dp
minus(other: Dp)

Subtract a Dp from another one.

operator Dp
plus(other: Dp)

Add two Dps together.

operator Dp
times(other: Float)

Multiply a Dp by a scalar.

operator Dp
times(other: Int)

String

operator Dp

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

Extension functions
From androidx.compose.ui.unit
Dp
Dp.coerceAtLeast(minimumValue: Dp)

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

Dp
Dp.coerceAtMost(maximumValue: Dp)

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

Dp
Dp.coerceIn(minimumValue: Dp, maximumValue: Dp)

Ensures that this value lies in the specified range minimumValue.

Dp
Dp.takeOrElse(block: () -> Dp)

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

Inherited extension functions
From androidx.core.util
infix Range<T>
T.rangeTo(that: T)

Creates a range from this Comparable value to that.

Properties
Float

Companion properties
Dp

A dimension used to represent a hairline drawing element.

Dp

Infinite dp dimension.

Dp

Constant that means unspecified Dp

Extension properties
From androidx.compose.ui.unit
Boolean

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

Boolean

false when this is Dp.Unspecified.

Boolean

true when this is Dp.Unspecified.

Public constructors

<init>

Dp(value: Float)

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. val leftMargin = 10.dp val rightMargin = 10f.dp val topMargin = 20.0.dp val bottomMargin = 10.dp Drawing is done in pixels. To retrieve the pixel size of a Dp, use toPx: val lineThicknessPx = lineThickness.toPx(context) toPx is normally needed only for painting operations.

Public methods

compareTo

@Stable operator fun compareTo(other: Dp): Int

Support comparing Dimensions with comparison operators.

div

@Stable inline operator fun div(other: Float):