SizeSpec

object SizeSpec

A SizeSpec encapsulates the layout requirements passed from parent to child. Each SizeSpec represents a requirement for either the width or the height. A SizeSpec is comprised of a size and a mode. There are two possible modes:

UNSPECIFIED : The parent has not imposed any constraint on the child. It can be whatever size it wants.

EXACTLY : The parent has determined an exact size for the child. The child is going to be given those bounds regardless of how big it wants to be. SizeSpecs are implemented as ints to reduce object allocation. This class is provided to pack and unpack the tuple into the int.

Types

Link copied to clipboard
annotation class MeasureSpecMode

Properties

Link copied to clipboard
const val AT_MOST: Int

Size specification mode: The child can be as large as it wants up to the specified size.

Link copied to clipboard
const val EXACTLY: Int

Size specification mode: The parent has determined an exact size for the child. The child is going to be given those bounds regardless of how big it wants to be.

Link copied to clipboard
const val NONE: Int

Size specification is not specified.

Link copied to clipboard
const val UNSPECIFIED: Int

Size specification mode: The parent has not imposed any constraint on the child. It can be whatever size it wants.

Functions

Link copied to clipboard
fun getMode(sizeSpec: Int): Int

Extracts the mode from the supplied size specification.

Link copied to clipboard
fun getSize(sizeSpec: Int): Int

Extracts the size from the supplied size specification.

Link copied to clipboard
fun makeSizeSpec(size: Int, mode: Int): Int

Creates a size specification based on the supplied size and mode.

Link copied to clipboard
fun makeSizeSpecFromCssSpec(cssSize: Float, cssMode: YogaMeasureMode): Int
Link copied to clipboard
fun resolveSize(sizeSpec: Int, preferredSize: Int): Int

Resolve a size spec given a preferred size.

Link copied to clipboard

Returns a simple String representation of the specified measure specification.

Link copied to clipboard
fun toString(sizeSpec: Int): String

Returns a String representation of the specified measure specification.