androidx.compose.ui.layout
MeasurePolicy
Fun interface · from org.jetbrains.compose.ui:ui:1.12.2
No hand-written docs yet.
Defines the measure and layout behavior of a Layout. Layout and MeasurePolicy are the way Compose layouts (such as Box, Column, etc.) are built, and they can also be used to achieve custom layouts.
fun interface MeasurePolicy
Used by
Parameters that take a MeasurePolicy.
Functions
measure
fun MeasureScope.measure(measurables: List<Measurable>, constraints: Constraints): MeasureResult
The function that defines the measurement and layout. Each Measurable in the measurables list corresponds to a layout child of the layout, and children can be measured using the Measurable.measure method. This method takes the Constraints which the child should respect; different children can be measured with different constraints.
minIntrinsicWidth
fun IntrinsicMeasureScope.minIntrinsicWidth(measurables: List<IntrinsicMeasurable>, height: Int): Int
The function used to calculate IntrinsicMeasurable.minIntrinsicWidth. It represents the minimum width this layout can take, given a specific height, such that the content of the layout can be painted correctly. There should be no side-effect from implementers of minIntrinsicWidth.
minIntrinsicHeight
fun IntrinsicMeasureScope.minIntrinsicHeight(measurables: List<IntrinsicMeasurable>, width: Int): Int
The function used to calculate IntrinsicMeasurable.minIntrinsicHeight. It represents the minimum height this layout can take, given a specific width, such that the content of the layout will be painted correctly. There should be no side-effect from implementers of minIntrinsicHeight.
maxIntrinsicWidth
fun IntrinsicMeasureScope.maxIntrinsicWidth(measurables: List<IntrinsicMeasurable>, height: Int): Int
The function used to calculate IntrinsicMeasurable.maxIntrinsicWidth. It represents the minimum width such that increasing it further will not decrease the minimum intrinsic height. There should be no side-effects from implementers of maxIntrinsicWidth.
maxIntrinsicHeight
fun IntrinsicMeasureScope.maxIntrinsicHeight(measurables: List<IntrinsicMeasurable>, width: Int): Int
The function used to calculate IntrinsicMeasurable.maxIntrinsicHeight. It represents the minimum height such that increasing it further will not decrease the minimum intrinsic width. There should be no side-effects from implementers of maxIntrinsicHeight.
Library docs
Defines the measure and layout behavior of a Layout. Layout and MeasurePolicy are the way
Compose layouts (such as Box, Column, etc.) are built, and they can also be used to achieve
custom layouts.
See Layout samples for examples of how to use MeasurePolicy.
Intrinsic measurement methods define the intrinsic size of the layout. These can be queried by the layout's parent in order to obtain, in specific cases, more information about the size of the layout in the absence of specific constraints:
minIntrinsicWidthdefines the minimum width this layout can take, given a specific height, such that the content of the layout will be painted correctlyminIntrinsicHeightdefines the minimum height this layout can take, given a specific width, such that the content of the layout will be painted correctlymaxIntrinsicWidthdefines the minimum width such that increasing it further will not decrease the minimum intrinsic heightmaxIntrinsicHeightdefines the minimum height such that increasing it further will not decrease the minimum intrinsic width
Most layout scenarios do not require querying intrinsic measurements. Therefore, when writing a
custom layout, it is common to only define the actual measurement, as most of the times the
intrinsic measurements of the layout will not be queried. Moreover, intrinsic measurement methods
have default implementations that make a best effort attempt to calculate the intrinsic
measurements by reusing the measure method. Note this will not be correct for all layouts, but
can be a convenient approximation.
Intrinsic measurements can be useful when the layout system enforcement of no more than one
measurement per child is limiting. Layouts that use them are the preferredWidth(IntrinsicSize)
and preferredHeight(IntrinsicSize) modifiers. See their samples for when they can be useful.