Skip to content

Constraints

@Immutable



class Constraints(
    val minWidth: Int = 0, 
    val maxWidth: Int = Int.MAX_VALUE, 
    val minHeight: Int = 0, 
    val maxHeight: Int = Int.MAX_VALUE
)

Immutable size constraints passed from a parent layout to its children during measurement.

A child must produce a size whose width is in [minWidth, maxWidth] and whose height is in [minHeight, maxHeight]. Use copy to derive a modified copy with some dimensions changed, and offset to shrink the available space by a fixed amount (e.g. for padding).

Constructors

Constraints

constructor(
    minWidth: Int = 0, 
    maxWidth: Int = Int.MAX_VALUE, 
    minHeight: Int = 0, 
    maxHeight: Int = Int.MAX_VALUE
)

Properties

maxHeight

val maxHeight: Int

maxWidth

val maxWidth: Int

minHeight

val minHeight: Int

minWidth

val minWidth: Int

Functions

copy

fun copy(
    minWidth: Int = this.minWidth, 
    maxWidth: Int = this.maxWidth, 
    minHeight: Int = this.minHeight, 
    maxHeight: Int = this.maxHeight
): Constraints

offset

@Stable



fun Constraints.offset(horizontal: Int = 0, vertical: Int = 0): Constraints

Returns a copy of these Constraints expanded or shrunk by horizontal pixels on each horizontal side and vertical pixels on each vertical side.

Negative values shrink the available space (useful for padding). maxWidth and maxHeight are never reduced below zero.