Google is committed to advancing racial equity for Black communities. See how.

PxSquared

@Immutable inline class PxSquared : Comparable<PxSquared>
kotlin.Any
   ↳ androidx.ui.unit.PxSquared

Holds a unit of squared dimensions, such as 1.value * 2.px. PxSquared, PxCubed, and PxInverse are used primarily for pixel calculations to ensure resulting units are as expected. Many times, pixel calculations use scalars to determine the final dimension during calculation: val width = oldWidth * stretchAmount Other times, it is useful to do intermediate calculations with Dimensions directly: val width = oldWidth * newTotalWidth / oldTotalWidth

Summary

Public constructors
<init>(value: Float)

Holds a unit of squared dimensions, such as 1.value * 2.px.

Public methods
operator Int

Support comparing PxSquared with comparison operators.

operator PxSquared
div(other: Float)

Divide a DimensionSquare by a scalar.

operator Float
div(other: PxSquared)

Divide by a PxSquared to get a scalar result.

operator PxInverse
div(other: PxCubed)

Divide by a PxCubed to get a PxInverse result.

operator PxSquared
minus(other: PxSquared)

Subtract a DimensionSquare from another one.

operator PxSquared
plus(other: PxSquared)

Add two DimensionSquares together.

operator PxSquared
times(other: Float)

Multiply by a scalar to get a PxSquared result.

String

Properties
Float

Public constructors

<init>

PxSquared(value: Float)

Holds a unit of squared dimensions, such as 1.value * 2.px. PxSquared, PxCubed, and PxInverse are used primarily for pixel calculations to ensure resulting units are as expected. Many times, pixel calculations use scalars to determine the final dimension during calculation: val width = oldWidth * stretchAmount Other times, it is useful to do intermediate calculations with Dimensions directly: val width = oldWidth * newTotalWidth / oldTotalWidth

Public methods

compareTo

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

Support comparing PxSquared with comparison operators.

div

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

Divide a DimensionSquare by a scalar.

div

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

Divide by a PxSquared to get a scalar result.

div

@Stable inline operator fun div(other: PxCubed): PxInverse

Divide by a PxCubed to get a PxInverse result.

minus

@Stable inline operator fun minus(other: PxSquared): PxSquared

Subtract a DimensionSquare from another one.

plus

@Stable inline operator fun plus(other: PxSquared): PxSquared

Add two DimensionSquares together.

times

@Stable inline operator fun times(other: Float): PxSquared

Multiply by a scalar to get a PxSquared result.

toString

@Stable fun toString(): String

Properties

value

val value: Float