FlexScope

sealed class FlexScope
kotlin.Any
   ↳ androidx.ui.layout.FlexScope

A FlexScope provides a scope for Inflexible/Flexible functions.

Summary

Public methods

LayoutModifier
Flexible(flex: Float, tight: Boolean = true)

A layout modifier within a Column or Row that makes the target component flexible.

LayoutModifier
Gravity.RelativeToSiblings(alignmentLineBlock: (Placeable) -> IntPx)

A layout modifier within a Column or Row that positions target component in a perpendicular direction according to the AlignmentLine which is provided through the alignmentLineBlock.

Properties

LayoutModifier

A layout modifier within a Column or Row that makes the target component inflexible.

Public methods

Flexible

fun Flexible(
    flex: Float,
    tight: Boolean = true
): LayoutModifier

A layout modifier within a Column or Row that makes the target component flexible. It will be assigned a space according to its flex weight relative to the flexible siblings. When tight is set to true, the target component is forced to occupy the entire space assigned to it by the parent. Flexible children will be measured after all the Inflexible ones have been measured, in order to divide the unclaimed space between them.

RelativeToSiblings

fun Gravity.RelativeToSiblings(alignmentLineBlock: (Placeable) -> IntPx): LayoutModifier

A layout modifier within a Column or Row that positions target component in a perpendicular direction according to the AlignmentLine which is provided through the alignmentLineBlock. If target component is the only component with the specified RelativeToSiblings modifier within a Column or Row, then the component will be positioned using ColumnScope.Gravity.Start in Column or RowScope.Gravity.Top in Row respectively.

Example usage:

import androidx.ui.layout.Column

Column {
    // Center of the first rectangle is aligned to the right edge of the second rectangle and
    // left edge of the third one.
    SizedRectangle(
        Gravity.RelativeToSiblings { it.width * 0.5 },
        color = Color.Blue,
        width = 80.dp,
        height = 40.dp
    )
    SizedRectangle(
        Gravity.RelativeToSiblings { it.width },
        color = Color.Magenta,
        width = 80.dp,
        height = 40.dp
    )
    SizedRectangle(
        Gravity.RelativeToSiblings { 0.ipx },
        color = Color.Red,
        width = 80.dp,
        height = 40.dp
    )
}

Properties

Inflexible

val Inflexible: LayoutModifier

A layout modifier within a Column or Row that makes the target component inflexible. All Inflexible children will be measured before the Flexible ones. They will be measured in the order they appear, without min constraints and with max constraints in the main direction of the layout (maxHeight for Column and maxWidth for Row) such that the sum of the space occupied by inflexible children will not exceed the incoming constraint of the Column or Row: for example the first child of a Column will be measured with maxHeight = column's maxHeight; the second child will be measured with maxHeight = column's maxHeight - first child's height, and so on.