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

Size

@Immutable inline class Size
kotlin.Any
   ↳ androidx.compose.ui.geometry.Size

Holds a 2D floating-point size.

You can think of this as an Offset from the origin.

Summary

Public constructors
<init>(packedValue: Long)

Holds a 2D floating-point size.

Public methods
operator Float

operator Float

Size
copy(width: Float = this.width, height: Float = this.height)

Returns a copy of this Size instance optionally overriding the width or height parameter

operator Size
div(operand: Float)

Division operator.

Boolean

Whether this size encloses a non-zero area.

operator Size
times(operand: Float)

Multiplication operator.

String

Extension functions
From androidx.compose.ui.unit
Offset

Returns the Offset of the center of the rect from the point of 0,0 with this Size.

PxBounds

Convert a Size to a PxBounds.

From androidx.compose.ui.layout
operator Size
Size.div(scaleFactor: ScaleFactor)

Division operator with Size

operator Size
Size.times(scaleFactor: ScaleFactor)

Multiplication operator with Size.

From androidx.compose.ui.geometry
Rect

Convert a Size to a Rect.

Properties
Float

Float

The greater of the magnitudes of the width and the height.

Float

The lesser of the magnitudes of the width and the height.

Float

Companion properties
Size

A size whose width and height are unspecified.

Size

An empty size, one with a zero width and a zero height.

Public constructors

<init>

Size(packedValue: Long)

Holds a 2D floating-point size.

You can think of this as an Offset from the origin.

Public methods

component1

@Stable inline operator fun component1(): Float

component2

@Stable inline operator fun component2(): Float

copy

fun copy(
    width: Float = this.width,
    height: Float = this.height
): Size

Returns a copy of this Size instance optionally overriding the width or height parameter

div

@Stable operator fun div(operand: Float): Size

Division operator.

Returns a Size whose dimensions are the dimensions of the left-hand-side operand (a Size) divided by the scalar right-hand-side operand (a Float).

isEmpty

@Stable fun isEmpty(): Boolean

Whether this size encloses a non-zero area.

Negative areas are considered empty.

times

@Stable operator fun times(operand: Float): Size

Multiplication operator.

Returns a Size whose dimensions are the dimensions of the left-hand-side operand (a Size) multiplied by the scalar right-hand-side operand (a Float).

toString

fun toString(): String

Properties

height

@Stable val height: Float

maxDimension

@Stable val maxDimension: Float

The greater of the magnitudes of the width and the height.

minDimension

@Stable val minDimension: Float

The lesser of the magnitudes of the width and the height.

width

@Stable val width: Float

Companion properties

Unspecified

@Stable val Unspecified: Size

A size whose width and height are unspecified. This is a sentinel value used to initialize a non-null parameter. Access to width or height on an unspecified size is not allowed

Zero

@Stable val Zero: Size

An empty size, one with a zero width and a zero height.