6월 3일의 ⁠#Android11: 베타 버전 출시 행사에 참여하세요.

Dp

`@Immutable inline class Dp : Comparable<Dp>`
 kotlin.Any ↳ androidx.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 DpInverse
`div(other: DpSquared)`

Divide by DpSquared to get a DpInverse.

operator Dp
`minus(other: Dp)`

Subtract a Dp from another one.

operator Dp
`plus(other: Dp)`

operator Dp
`times(other: Float)`

Multiply a Dp by a scalar.

operator Dp
`times(other: Int)`

operator DpSquared
`times(other: Dp)`

Multiply by a Dp to get a DpSquared result.

operator DpCubed
`times(other: DpSquared)`

Multiply by a Dp to get a DpSquared result.

String
`toString()`

operator Dp
`unaryMinus()`

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

Extension functions

From androidx.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. Boolean `Dp.isFinite()` Return `true` when it is finite or `false` when it is Dp.Infinity

Float
`value`

Companion properties

Dp
`Hairline`

A dimension used to represent a hairline drawing element.

Dp
`Infinity`

Infinite dp dimension.

Dp
`Unspecified`

Constant that means unspecified Dp

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

`operator fun compareTo(other: Dp): Int`

Support comparing Dimensions with comparison operators.

div

`inline operator fun div(other: Float): Dp`

Divide a Dp by a scalar.

div

`inline operator fun div(other: Int): Dp`

div

`inline operator fun div(other: Dp): Float`

Divide by another Dp to get a scalar.

div

`inline operator fun div(other: DpSquared): DpInverse`

Divide by DpSquared to get a DpInverse.

minus

`inline operator fun minus(other: Dp): Dp`

Subtract a Dp from another one.

plus

`inline operator fun plus(other: Dp): Dp`

times

`inline operator fun times(other: Float): Dp`

Multiply a Dp by a scalar.

times

`inline operator fun times(other: Int): Dp`

times

`inline operator fun times(other: Dp): DpSquared`

Multiply by a Dp to get a DpSquared result.

times

`inline operator fun times(other: DpSquared): DpCubed`

Multiply by a Dp to get a DpSquared result.

toString

`fun toString(): String`

unaryMinus

`inline operator fun unaryMinus(): Dp`

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

Properties

value

`val value: Float`

Companion 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