Px

@Immutable data class Px : Comparable<Px>
kotlin.Any
   ↳ androidx.ui.core.Px

Dimension value represented in pixels (px). Component APIs specify their dimensions such as line thickness in DP with Dp objects, while drawing and layout are done in pixel dimensions. When specific pixel dimensions are required, create a Px and convert it to Dp using DensityScope.toDp. Px are normally defined using px, which can be applied to Int, Double, and Float. val leftMargin = 10.px val rightMargin = 10f.px val topMargin = 20.0.px val bottomMargin = 10.px

Summary

Public constructors

<init>(value: Float)

Dimension value represented in pixels (px).

Public methods

operator Int
compareTo(other: Px)

Compare Px with another Px.

operator Int
compareTo(other: IntPx)

Compares this Px to another IntPx

operator Px
div(other: Float)

Divide a Px by a scalar.

operator Px
div(other: Int)

operator Float
div(other: Px)

Divide by another Px to get a scalar.

operator PxInverse
div(other: PxSquared)

Divide by PxSquared to get a PxInverse.

operator Px
minus(other: Px)

Subtract a Px from another one.

operator Px
minus(other: IntPx)

Subtract an IntPx from this Px.

operator Px
plus(other: Px)

Add two Pxs together.

operator Px
plus(other: IntPx)

Add an IntPx to this Px.

operator Px
times(other: Float)

Multiply a Px by a scalar.

operator Px
times(other: Int)

operator PxSquared
times(other: Px)

Multiply by a Px to get a PxSquared result.

operator PxCubed
times(other: PxSquared)

Multiply by a Px to get a PxSquared result.

String

operator Px

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

Extension functions

From androidx.ui.core
Px
Px.coerceAtLeast(minimumValue: Px)

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

Px
Px.coerceAtMost(maximumValue: Px)

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

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

Ensures that this value lies in the specified range minimumValue.

IntPx

Rounds a Px size to the nearest Int pixel value.

Properties

Float

Companion properties

Px

Infinite px dimension.

Px

Zero px dimension

Public constructors

<init>

Px(value: Float)

Dimension value represented in pixels (px). Component APIs specify their dimensions such as line thickness in DP with Dp objects, while drawing and layout are done in pixel dimensions. When specific pixel dimensions are required, create a Px and convert it to Dp using DensityScope.toDp. Px are normally defined using px, which can be applied to Int, Double, and Float. val leftMargin = 10.px val rightMargin = 10f.px val topMargin = 20.0.px val bottomMargin = 10.px

Public methods

compareTo

inline operator fun compareTo(other: Px): Int

Compare Px with another Px.

compareTo

inline operator fun compareTo(other: IntPx): Int

Compares this Px to another IntPx

div

inline operator fun div(other: Float): Px

Divide a Px by a scalar.

div

inline operator fun div(other: Int): Px

div

inline operator fun div(other: Px): Float

Divide by another Px to get a scalar.

div

inline operator fun div(other: PxSquared): PxInverse

Divide by PxSquared to get a PxInverse.

minus

inline operator fun minus(other: Px): Px

Subtract a Px from another one.

minus

inline operator fun minus(other: IntPx): Px

Subtract an IntPx from this Px.

plus

inline operator fun plus(other: Px): Px

Add two Pxs together.

plus

inline operator fun plus(other: IntPx): Px

Add an IntPx to this Px.

times

inline operator fun times(other: Float): Px

Multiply a Px by a scalar.

times

inline operator fun times(other: Int): Px

times

inline operator fun times(other: Px): PxSquared

Multiply by a Px to get a PxSquared result.

times

inline operator fun times(other: PxSquared): PxCubed

Multiply by a Px to get a PxSquared result.

toString

fun toString(): String

unaryMinus

inline operator fun unaryMinus(): Px

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

Properties

value

val value: Float

Companion properties

Infinity

val Infinity: Px

Infinite px dimension.

Zero

val Zero: Px

Zero px dimension