The Developer Preview for Android 11 is now available; test it out and share your feedback.

FlexScope

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

Base class for scopes of Row and Column, containing scoped modifiers.

Summary

Public methods

ParentDataModifier
LayoutFlexible(flex: Float, tight: Boolean = true)

A layout modifier within a Column or Row that makes the target component flexible in the main direction of the parent (vertically in Column and horizontally in Row).

ParentDataModifier
LayoutGravity.RelativeToSiblings(alignmentLineBlock: (Placeable) -> IntPx)

A layout modifier within a Column or Row that positions its target component relative to all other elements within the container which have LayoutGravity.RelativeToSiblings.

Inherited extension functions

From androidx.compose
operator T

IMPORTANT: This global operator is TEMPORARY, and should be removed whenever an answer for contextual composers is reached.

Public methods

LayoutFlexible

fun LayoutFlexible(
    flex: Float,
    tight: Boolean = true
): ParentDataModifier

A layout modifier within a Column or Row that makes the target component flexible in the main direction of the parent (vertically in Column and horizontally in Row). It will be assigned a space according to its flex weight, proportional to the flex weights of other flexible siblings. If a sibling is not flexible, its flex weight will be 0. When tight is set to true, the target component is forced to occupy the entire space assigned to it by the parent. LayoutFlexible children will be measured after all the inflexible ones have been measured, in order to divide the unclaimed space between them.

RelativeToSiblings

fun LayoutGravity.RelativeToSiblings(alignmentLineBlock: (Placeable) -> IntPx): ParentDataModifier

A layout modifier within a Column or Row that positions its target component relative to all other elements within the container which have LayoutGravity.RelativeToSiblings. The alignmentLineBlock accepts the Placeable of the targeted layout and returns the position, perpendicular to the layout direction, along which the target should align such that it coincides with the alignment lines of all other siblings with LayoutGravity.RelativeToSiblings. Within a Column or Row, all components with LayoutGravity.RelativeToSiblings will align using the specified AlignmentLines or values obtained from alignmentLineBlocks, forming a sibling group. At least one element of the sibling group will be placed as it had LayoutGravity.Start in Column or LayoutGravity.Top in Row, respectively, and the alignment of the other siblings will be then determined such that the alignment lines coincide. Note that if the target component is the only one with the RelativeToSiblings modifier specified, then the component will be positioned using LayoutGravity.Start in Column or LayoutGravity.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(
        LayoutGravity.RelativeToSiblings { it.width * 0.5 },
        color = Color.Blue,
        width = 80.dp,
        height = 40.dp
    )
    SizedRectangle(
        LayoutGravity.RelativeToSiblings { it.width },
        color = Color.Magenta,
        width = 80.dp,
        height = 40.dp
    )
    SizedRectangle(
        LayoutGravity.RelativeToSiblings { 0.ipx },
        color = Color.Red,
        width = 80.dp,
        height = 40.dp
    )
}