@MeasureScopeMarker
@JvmDefaultWithCompatibility
interface MeasureScope : IntrinsicMeasureScope
The receiver scope of a layout's measure lambda. The return value of the measure lambda is MeasureResult, which should be returned by layout
Functions
layout
fun layout(
width: Int,
height: Int,
alignmentLines: Map<AlignmentLine, Int> = emptyMap(),
placementBlock: Placeable.PlacementScope.() -> Unit,
) = layout(width, height, alignmentLines, null, placementBlock)
Sets the size and alignment lines of the measured layout, as well as the positioning block that defines the children positioning logic. The placementBlock is a lambda used for positioning children. Placeable.placeAt should be called on children inside placementBlock. The alignmentLines can be used by the parent layouts to decide layout, and can be queried using the Placeable.get operator. Note that alignment lines will be inherited by parent layouts, such that indirect parents will be able to query them as well.
Parameters
| width | the measured width of the layout |
| height | the measured height of the layout |
| alignmentLines | the alignment lines defined by the layout |
| placementBlock | block defining the children positioning of the current layout |
layout
fun layout(
width: Int,
height: Int,
alignmentLines: Map<AlignmentLine, Int> = emptyMap(),
rulers: (RulerScope.() -> Unit)? = null,
placementBlock: Placeable.PlacementScope.() -> Unit,
): MeasureResult
Sets the size and alignment lines of the measured layout, as well as the positioning block that defines the children positioning logic. The placementBlock is a lambda used for positioning children. Placeable.placeAt should be called on children inside placementBlock. The alignmentLines can be used by the parent layouts to decide layout, and can be queried using the Placeable.get operator. Note that alignment lines will be inherited by parent layouts, such that indirect parents will be able to query them as well.
Parameters
| width | the measured width of the layout |
| height | the measured height of the layout |
| alignmentLines | the alignment lines defined by the layout |
| rulers | a method to set Ruler values used by all placed children |
| placementBlock | block defining the children positioning of the current layout |
layout
fun layout(
width: Int,
height: Int,
isRulerProvided: (Ruler) -> Boolean,
rulerProvider: RulerScope.(Ruler) -> Unit,
alignmentLines: Map<AlignmentLine, Int> = emptyMap(),
placementBlock: Placeable.PlacementScope.() -> Unit,
): MeasureResult
Sets the size and alignment lines of the measured layout, as well as the positioning block that defines the children positioning logic. The placementBlock is a lambda used for positioning children. Placeable.placeAt should be called on children inside placementBlock. The alignmentLines can be used by the parent layouts to decide layout, and can be queried using the Placeable.get operator. Note that alignment lines will be inherited by parent layouts, such that indirect parents will be able to query them as well.
Use this version when providing the Rulers is expensive and should only be done when needed.
Parameters
| width | the measured width of the layout |
| height | the measured height of the layout |
| alignmentLines | the alignment lines defined by the layout |
| isRulerProvided | Works in conjunction with rulerProvider to provide Ruler values individually. A return value of true indicates that rulerProvider might be able to provide a value for the passed-in Ruler. A value of false means it can never provide the value. |
| rulerProvider | A lambda that can provide Ruler values. When isRulerProvided returns true for a Ruler, rulerProvider will be called to provide its value. rulerProvider can choose not to provide the value if it isn't available. It can also provide more Ruler values if it is convenient to provide them. For example, it may be convenient to provide all values for a RectRulers when one is provided. |
| placementBlock | block defining the children positioning of the current layout |