abstract class ConstraintLayoutBaseScope

Known direct subclasses
ConstraintLayoutScope

Scope used by the inline DSL of ConstraintLayout.

ConstraintSetScope

Scope used by the ConstraintSet DSL.


Common scope for ConstraintLayoutScope and ConstraintSetScope, the content being shared between the inline DSL API and the ConstraintSet-based API.

Summary

Nested types

Represents a horizontal anchor corresponding to the FirstBaseline of a layout that other layouts can link to in their Modifier.constrainAs or constrain blocks.

Represents a horizontal anchor (e.g. top/bottom of a layout, guideline) that layouts can link to in their Modifier.constrainAs or constrain blocks.

Represents a vertical anchor (e.g. start/end of a layout, guideline) that layouts can link to in their Modifier.constrainAs or constrain blocks.

Public constructors

Public functions

Unit
applyTo(state: State)
ConstrainScope

Specifies the constraints associated to the layout identified with ref.

HorizontalChainScope

Specifies additional constraints associated to the horizontal chain identified with ref.

VerticalChainScope

Specifies additional constraints associated to the vertical chain identified with ref.

Unit
constrain(
    vararg refs: ConstrainedLayoutReference,
    constrainBlock: ConstrainScope.() -> Unit
)

Convenient way to apply the same constraints to multiple ConstrainedLayoutReferences.

ConstraintLayoutBaseScope.VerticalAnchor
createAbsoluteLeftBarrier(vararg elements: LayoutReference, margin: Dp)

Creates and returns a left barrier, containing the specified elements.

ConstraintLayoutBaseScope.VerticalAnchor
createAbsoluteRightBarrier(vararg elements: LayoutReference, margin: Dp)

Creates and returns a right barrier, containing the specified elements.

ConstraintLayoutBaseScope.HorizontalAnchor
createBottomBarrier(vararg elements: LayoutReference, margin: Dp)

Creates and returns a bottom barrier, containing the specified elements.

ConstrainedLayoutReference
createColumn(
    vararg elements: LayoutReference,
    skips: Array<Skip>,
    spans: Array<Span>,
    rowWeights: IntArray,
    verticalGap: Dp,
    padding: Dp
)

Creates a Grid based helper that lays out its elements in a single Column.

ConstrainedLayoutReference
createColumn(
    vararg elements: LayoutReference,
    skips: Array<Skip>,
    spans: Array<Span>,
    verticalGap: Dp,
    rowWeights: IntArray,
    paddingHorizontal: Dp,
    paddingVertical: Dp
)

Creates a Grid based helper that lays out its elements in a single Column.

ConstraintLayoutBaseScope.VerticalAnchor
createEndBarrier(vararg elements: LayoutReference, margin: Dp)

Creates and returns an end barrier, containing the specified elements.

ConstrainedLayoutReference
createFlow(
    vararg elements: LayoutReference?,
    flowVertically: Boolean,
    verticalGap: Dp,
    horizontalGap: Dp,
    maxElement: Int,
    padding: Dp,
    wrapMode: Wrap,
    verticalAlign: VerticalAlign,
    horizontalAlign: HorizontalAlign,
    horizontalFlowBias: Float,
    verticalFlowBias: Float,
    verticalStyle: FlowStyle,
    horizontalStyle: FlowStyle
)

Flow helpers allows a long sequence of Composable widgets to wrap onto multiple rows or columns.

ConstrainedLayoutReference
createFlow(
    vararg elements: LayoutReference?,
    flowVertically: Boolean,
    verticalGap: Dp,
    horizontalGap: Dp,
    maxElement: Int,
    paddingHorizontal: Dp,
    paddingVertical: Dp,
    wrapMode: Wrap,
    verticalAlign: VerticalAlign,
    horizontalAlign: HorizontalAlign,
    horizontalFlowBias: Float,
    verticalFlowBias: Float,
    verticalStyle: FlowStyle,
    horizontalStyle: FlowStyle
)

Flow helpers allows a long sequence of Composable widgets to wrap onto multiple rows or columns.

ConstrainedLayoutReference
createFlow(
    vararg elements: LayoutReference?,
    flowVertically: Boolean,
    verticalGap: Dp,
    horizontalGap: Dp,
    maxElement: Int,
    paddingLeft: Dp,
    paddingTop: Dp,
    paddingRight: Dp,
    paddingBottom: Dp,
    wrapMode: Wrap,
    verticalAlign: VerticalAlign,
    horizontalAlign: HorizontalAlign,
    horizontalFlowBias: Float,
    verticalFlowBias: Float,
    verticalStyle: FlowStyle,
    horizontalStyle: FlowStyle
)

Flow helpers allows a long sequence of Composable widgets to wrap onto multiple rows or columns.

ConstrainedLayoutReference
createGrid(
    vararg elements: LayoutReference,
    orientation: Int,
    rows: Int,
    columns: Int,
    verticalGap: Dp,
    horizontalGap: Dp,
    rowWeights: IntArray,
    columnWeights: IntArray,
    skips: Array<Skip>,
    spans: Array<Span>,
    padding: Dp,
    flags: Array<GridFlag>
)

Creates a Grid representation with a Grid Helper.

ConstrainedLayoutReference
createGrid(
    vararg elements: LayoutReference,
    orientation: Int,
    rows: Int,
    columns: Int,
    verticalGap: Dp,
    horizontalGap: Dp,
    rowWeights: IntArray,
    columnWeights: IntArray,
    skips: Array<Skip>,
    spans: Array<Span>,
    paddingHorizontal: Dp,
    paddingVertical: Dp,
    flags: Array<GridFlag>
)

Creates a Grid representation with a Grid Helper.

ConstrainedLayoutReference
createGrid(
    vararg elements: LayoutReference,
    orientation: Int,
    rows: Int,
    columns: Int,
    verticalGap: Dp,
    horizontalGap: Dp,
    rowWeights: IntArray,
    columnWeights: IntArray,
    skips: Array<Skip>,
    spans: Array<Span>,
    paddingStart: Dp,
    paddingTop: Dp,
    paddingEnd: Dp,
    paddingBottom: Dp,
    flags: Array<GridFlag>
)

Creates a Grid representation with a Grid Helper.

ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a width fraction from the left of the ConstraintLayout.

ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the left of the ConstraintLayout.

ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a width fraction from the right of the ConstraintLayout.

ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the right of the ConstraintLayout.

ConstraintLayoutBaseScope.HorizontalAnchor

Creates a guideline at a height percentage from the bottom of the ConstraintLayout.

ConstraintLayoutBaseScope.HorizontalAnchor

Creates a guideline at a specific offset from the bottom of the ConstraintLayout.

ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a width fraction from the end of the ConstraintLayout.

ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the end of the ConstraintLayout.

ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the start of the ConstraintLayout.

ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the start of the ConstraintLayout.

ConstraintLayoutBaseScope.HorizontalAnchor

Creates a guideline at a height fraction from the top of the ConstraintLayout.

ConstraintLayoutBaseScope.HorizontalAnchor

Creates a guideline at a specific offset from the top of the ConstraintLayout.

HorizontalChainReference
createHorizontalChain(
    vararg elements: LayoutReference,
    chainStyle: ChainStyle
)

Creates a horizontal chain including the referenced layouts.

ConstrainedLayoutReference
createRow(
    vararg elements: LayoutReference,
    skips: Array<Skip>,
    spans: Array<Span>,
    horizontalGap: Dp,
    columnWeights: IntArray,
    padding: Dp
)

Creates a Grid based helper that lays out its elements in a single Row.

ConstrainedLayoutReference
createRow(
    vararg elements: LayoutReference,
    skips: Array<Skip>,
    spans: Array<Span>,
    horizontalGap: Dp,
    columnWeights: IntArray,
    paddingHorizontal: Dp,
    paddingVertical: Dp
)

Creates a Grid based helper that lays out its elements in a single Row.

ConstraintLayoutBaseScope.VerticalAnchor
createStartBarrier(vararg elements: LayoutReference, margin: Dp)

Creates and returns a start barrier, containing the specified elements.

ConstraintLayoutBaseScope.HorizontalAnchor
createTopBarrier(vararg elements: LayoutReference, margin: Dp)

Creates and returns a top barrier, containing the specified elements.

VerticalChainReference
createVerticalChain(
    vararg elements: LayoutReference,
    chainStyle: ChainStyle
)

Creates a vertical chain including the referenced layouts.

open operator Boolean
equals(other: Any?)
open Int
open Unit
LayoutReference
LayoutReference.withChainParams(
    startMargin: Dp,
    topMargin: Dp,
    endMargin: Dp,
    bottomMargin: Dp,
    startGoneMargin: Dp,
    topGoneMargin: Dp,
    endGoneMargin: Dp,
    bottomGoneMargin: Dp,
    weight: Float
)

Sets the parameters that are used by chains to customize the resulting layout.

LayoutReference
LayoutReference.withHorizontalChainParams(
    startMargin: Dp,
    endMargin: Dp,
    startGoneMargin: Dp,
    endGoneMargin: Dp,
    weight: Float
)

Sets the parameters that are used by horizontal chains to customize the resulting layout.

LayoutReference
LayoutReference.withVerticalChainParams(
    topMargin: Dp,
    bottomMargin: Dp,
    topGoneMargin: Dp,
    bottomGoneMargin: Dp,
    weight: Float
)

Sets the parameters that are used by vertical chains to customize the resulting layout.

Protected properties

MutableList<(State) -> Unit>

This property is deprecated. Tasks is unused, it breaks the immutability promise.

Public constructors

ConstraintLayoutBaseScope

Added in 1.1.0-alpha13
ConstraintLayoutBaseScope()

Public functions

applyTo

Added in 1.1.0-alpha13
fun applyTo(state: State): Unit

constrain

Added in 1.1.0-alpha13
fun constrain(ref: ConstrainedLayoutReference, constrainBlock: ConstrainScope.() -> Unit): ConstrainScope

Specifies the constraints associated to the layout identified with ref.

constrain

Added in 1.1.0-alpha13
fun constrain(ref: HorizontalChainReference, constrainBlock: HorizontalChainScope.() -> Unit): HorizontalChainScope

Specifies additional constraints associated to the horizontal chain identified with ref.

constrain

Added in 1.1.0-alpha13
fun constrain(ref: VerticalChainReference, constrainBlock: VerticalChainScope.() -> Unit): VerticalChainScope

Specifies additional constraints associated to the vertical chain identified with ref.

constrain

fun constrain(
    vararg refs: ConstrainedLayoutReference,
    constrainBlock: ConstrainScope.() -> Unit
): Unit

Convenient way to apply the same constraints to multiple ConstrainedLayoutReferences.

createAbsoluteLeftBarrier

fun createAbsoluteLeftBarrier(
    vararg elements: LayoutReference,
    margin: Dp = 0.dp
): ConstraintLayoutBaseScope.VerticalAnchor

Creates and returns a left barrier, containing the specified elements.

createAbsoluteRightBarrier

fun createAbsoluteRightBarrier(
    vararg elements: LayoutReference,
    margin: Dp = 0.dp
): ConstraintLayoutBaseScope.VerticalAnchor

Creates and returns a right barrier, containing the specified elements.

createBottomBarrier

fun createBottomBarrier(vararg elements: LayoutReference, margin: Dp = 0.dp): ConstraintLayoutBaseScope.HorizontalAnchor

Creates and returns a bottom barrier, containing the specified elements.

createColumn

fun createColumn(
    vararg elements: LayoutReference,
    skips: Array<Skip> = arrayOf(),
    spans: Array<Span> = arrayOf(),
    rowWeights: IntArray = intArrayOf(),
    verticalGap: Dp = 0.dp,
    padding: Dp = 0.dp
): ConstrainedLayoutReference

Creates a Grid based helper that lays out its elements in a single Column. Example: ConstraintLayout( ConstraintSet { val a = createRefFor("1") val b = createRefFor("2") val c = createRefFor("3") val d = createRefFor("4") val e = createRefFor("5") val weights = intArrayOf(3, 3, 2, 2, 1) val g1 = createColumn( a, b, c, d, e, skips = arrayOf(Skip(1, 1), Skip(3, 2)), spans = arrayOf(Span(1, 2)), verticalGap = 10.dp, rowWeights = weights, padding = 10.dp, ) constrain(g1) { width = Dimension.matchParent height = Dimension.matchParent }, modifier = Modifier.fillMaxSize() ) { val numArray = arrayOf("1", "2", "3", "4", "5") for (num in numArray) { Button( modifier = Modifier.layoutId(num).width(120.dp), onClick = {}, ) { Text(text = String.format("btn%s", num)) } } }

Parameters
vararg elements: LayoutReference

LayoutReferences to be laid out by the Grid helper

skips: Array<Skip> = arrayOf()

specify area(s) in a Column to be skipped - format: Skip(index, size)

spans: Array<Span> = arrayOf()

specify area(s) in a Column to be spanned - format: Span(index, size)

rowWeights: IntArray = intArrayOf()

defines the weight of each row

verticalGap: Dp = 0.dp

defines the gap between views in the y axis

padding: Dp = 0.dp

sets padding around the content

createColumn

fun createColumn(
    vararg elements: LayoutReference,
    skips: Array<Skip> = arrayOf(),
    spans: Array<Span> = arrayOf(),
    verticalGap: Dp = 0.dp,
    rowWeights: IntArray = intArrayOf(),
    paddingHorizontal: Dp = 0.dp,
    paddingVertical: Dp = 0.dp
): ConstrainedLayoutReference

Creates a Grid based helper that lays out its elements in a single Column. Example: ConstraintLayout( ConstraintSet { val a = createRefFor("1") val b = createRefFor("2") val c = createRefFor("3") val d = createRefFor("4") val e = createRefFor("5") val weights = intArrayOf(3, 3, 2, 2, 1) val g1 = createColumn( a, b, c, d, e, skips = arrayOf(Skip(1, 1), Skip(3, 2)), spans = arrayOf(Span(1, 2)), verticalGap = 10.dp, rowWeights = weights, padding = 10.dp, ) constrain(g1) { width = Dimension.matchParent height = Dimension.matchParent }, modifier = Modifier.fillMaxSize() ) { val numArray = arrayOf("1", "2", "3", "4", "5") for (num in numArray) { Button( modifier = Modifier.layoutId(num).width(120.dp), onClick = {}, ) { Text(text = String.format("btn%s", num)) } } }

Parameters
vararg elements: LayoutReference

LayoutReferences to be laid out by the Grid helper

skips: Array<Skip> = arrayOf()

specify area(s) in a Column to be skipped - format: Skip(index, size)

spans: Array<Span> = arrayOf()

specify area(s) in a Column to be spanned - format: Span(index, size)

verticalGap: Dp = 0.dp

defines the gap between views in the y axis

rowWeights: IntArray = intArrayOf()

defines the weight of each row

paddingHorizontal: Dp = 0.dp

sets paddingStart and paddingEnd of the content

paddingVertical: Dp = 0.dp

sets paddingTop and paddingBottom of the content

createEndBarrier

fun createEndBarrier(vararg elements: LayoutReference, margin: Dp = 0.dp): ConstraintLayoutBaseScope.VerticalAnchor

Creates and returns an end barrier, containing the specified elements.

createFlow

fun createFlow(
    vararg elements: LayoutReference?,
    flowVertically: Boolean = false,
    verticalGap: Dp = 0.dp,
    horizontalGap: Dp = 0.dp,
    maxElement: Int = 0,
    padding: Dp = 0.dp,
    wrapMode: Wrap = Wrap.None,
    verticalAlign: VerticalAlign = VerticalAlign.Center,
    horizontalAlign: HorizontalAlign = HorizontalAlign.Center,
    horizontalFlowBias: Float = 0.0f,
    verticalFlowBias: Float = 0.0f,
    verticalStyle: FlowStyle = FlowStyle.Packed,
    horizontalStyle: FlowStyle = FlowStyle.Packed
): ConstrainedLayoutReference

Flow helpers allows a long sequence of Composable widgets to wrap onto multiple rows or columns.

Parameters
vararg elements: LayoutReference?

LayoutReferences to be laid out by the Flow helper

flowVertically: Boolean = false

if set to true arranges the Composables from top to bottom. Normally they are arranged from left to right.

verticalGap: Dp = 0.dp

defines the gap between views in the y axis

horizontalGap: Dp = 0.dp

defines the gap between views in the x axis

maxElement: Int = 0

defines the maximum element on a row before it if the

padding: Dp = 0.dp

sets padding around the content

wrapMode: Wrap = Wrap.None

sets the way reach maxElements is handled Wrap.None (default) -- no wrap behavior, Wrap.Chain - create additional chains

verticalAlign: VerticalAlign = VerticalAlign.Center

set the way elements are aligned vertically. Center is default

horizontalAlign: HorizontalAlign = HorizontalAlign.Center

set the way elements are aligned horizontally. Center is default

horizontalFlowBias: Float = 0.0f

set the way elements are aligned vertically Center is default

verticalFlowBias: Float = 0.0f

sets the top bottom bias of the vertical chain

verticalStyle: FlowStyle = FlowStyle.Packed

sets the style of a vertical chain (Spread,Packed, or SpreadInside)

horizontalStyle: FlowStyle = FlowStyle.Packed

set the style of the horizontal chain (Spread, Packed, or SpreadInside)

createFlow

fun createFlow(
    vararg elements: LayoutReference?,
    flowVertically: Boolean = false,
    verticalGap: Dp = 0.dp,
    horizontalGap: Dp = 0.dp,
    maxElement: Int = 0,
    paddingHorizontal: Dp = 0.dp,
    paddingVertical: Dp = 0.dp,
    wrapMode: Wrap = Wrap.None,
    verticalAlign: VerticalAlign = VerticalAlign.Center,
    horizontalAlign: HorizontalAlign = HorizontalAlign.Center,
    horizontalFlowBias: Float = 0.0f,
    verticalFlowBias: Float = 0.0f,
    verticalStyle: FlowStyle = FlowStyle.Packed,
    horizontalStyle: FlowStyle = FlowStyle.Packed
): ConstrainedLayoutReference

Flow helpers allows a long sequence of Composable widgets to wrap onto multiple rows or columns.

Parameters
vararg elements: LayoutReference?

LayoutReferences to be laid out by the Flow helper

flowVertically: Boolean = false

if set to true aranges the Composables from top to bottom. Normally they are arranged from left to right.

verticalGap: Dp = 0.dp

defines the gap between views in the y axis

horizontalGap: Dp = 0.dp

defines the gap between views in the x axis

maxElement: Int = 0

defines the maximum element on a row before it if the

paddingHorizontal: Dp = 0.dp

sets paddingLeft and paddingRight of the content

paddingVertical: Dp = 0.dp

sets paddingTop and paddingBottom of the content

wrapMode: Wrap = Wrap.None

sets the way reach maxElements is handled Wrap.None (default) -- no wrap behavior, Wrap.Chain - create additional chains

verticalAlign: VerticalAlign = VerticalAlign.Center

set the way elements are aligned vertically. Center is default

horizontalAlign: HorizontalAlign = HorizontalAlign.Center

set the way elements are aligned horizontally. Center is default

horizontalFlowBias: Float = 0.0f

set the way elements are aligned vertically Center is default

verticalFlowBias: Float = 0.0f

sets the top bottom bias of the vertical chain

verticalStyle: FlowStyle = FlowStyle.Packed

sets the style of a vertical chain (Spread,Packed, or SpreadInside)

horizontalStyle: FlowStyle = FlowStyle.Packed

set the style of the horizontal chain (Spread, Packed, or SpreadInside)

createFlow

fun createFlow(
    vararg elements: LayoutReference?,
    flowVertically: Boolean = false,
    verticalGap: Dp = 0.dp,
    horizontalGap: Dp = 0.dp,
    maxElement: Int = 0,
    paddingLeft: Dp = 0.dp,
    paddingTop: Dp = 0.dp,
    paddingRight: Dp = 0.dp,
    paddingBottom: Dp = 0.dp,
    wrapMode: Wrap = Wrap.None,
    verticalAlign: VerticalAlign = VerticalAlign.Center,
    horizontalAlign: HorizontalAlign = HorizontalAlign.Center,
    horizontalFlowBias: Float = 0.0f,
    verticalFlowBias: Float = 0.0f,
    verticalStyle: FlowStyle = FlowStyle.Packed,
    horizontalStyle: FlowStyle = FlowStyle.Packed
): ConstrainedLayoutReference

Flow helpers allows a long sequence of Composable widgets to wrap onto multiple rows or columns.

Parameters
vararg elements: LayoutReference?

LayoutReferences to be laid out by the Flow helper

flowVertically: Boolean = false

if set to true aranges the Composables from top to bottom. Normally they are arranged from left to right.

verticalGap: Dp = 0.dp

defines the gap between views in the y axis

horizontalGap: Dp = 0.dp

defines the gap between views in the x axis

maxElement: Int = 0

defines the maximum element on a row before it if the

paddingLeft: Dp = 0.dp

sets paddingLeft of the content

paddingTop: Dp = 0.dp

sets paddingTop of the content

paddingRight: Dp = 0.dp

sets paddingRight of the content

paddingBottom: Dp = 0.dp

sets paddingBottom of the content

wrapMode: Wrap = Wrap.None

sets the way reach maxElements is handled Wrap.None (default) -- no wrap behavior, Wrap.Chain - create additional chains

verticalAlign: VerticalAlign = VerticalAlign.Center

set the way elements are aligned vertically. Center is default

horizontalAlign: HorizontalAlign = HorizontalAlign.Center

set the way elements are aligned horizontally. Center is default

horizontalFlowBias: Float = 0.0f

set the way elements are aligned vertically Center is default

verticalFlowBias: Float = 0.0f

sets the top bottom bias of the vertical chain

verticalStyle: FlowStyle = FlowStyle.Packed

sets the style of a vertical chain (Spread,Packed, or SpreadInside)

horizontalStyle: FlowStyle = FlowStyle.Packed

set the style of the horizontal chain (Spread, Packed, or SpreadInside)

createGrid

fun createGrid(
    vararg elements: LayoutReference,
    orientation: Int = 0,
    rows: Int = 0,
    columns: Int = 0,
    verticalGap: Dp = 0.dp,
    horizontalGap: Dp = 0.dp,
    rowWeights: IntArray = intArrayOf(),
    columnWeights: IntArray = intArrayOf(),
    skips: Array<Skip> = arrayOf(),
    spans: Array<Span> = arrayOf(),
    padding: Dp = 0.dp,
    flags: Array<GridFlag> = arrayOf()
): ConstrainedLayoutReference

Creates a Grid representation with a Grid Helper. Example: ConstraintLayout( ConstraintSet { val a = createRefFor("1") val b = createRefFor("2") val c = createRefFor("3") val d = createRefFor("4") val e = createRefFor("5") val f = createRefFor("6") val g = createRefFor("7") val h = createRefFor("8") val i = createRefFor("9") val j = createRefFor("0") val k = createRefFor("box") val weights = intArrayOf(3, 3, 2, 2) val flags = arrayOf("SubGridByColRow", "SpansRespectWidgetOrder") val g1 = createGrid( k, a, b, c, d, e, f, g, h, i, j, k, rows = 5, columns = 3, verticalGap = 25.dp, horizontalGap = 25.dp, skips = arrayOf(Skip(12, 1, 1)), spans = arrayOf(Span(0, 1, 3)), rowWeights = weights, paddingHorizontal = 10.dp, paddingVertical = 10.dp, flags = flags, ) constrain(g1) { width = Dimension.matchParent height = Dimension.matchParent }, modifier = Modifier.fillMaxSize() ) { val numArray = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "0") for (num in numArray) { Button( modifier = Modifier.layoutId(num).width(120.dp), onClick = {}, ) { Text(text = String.format("btn%s", num)) } } Box( modifier = Modifier.background(Color.Gray).layoutId("box"), Alignment.BottomEnd ) { Text("100", fontSize = 80.sp) } }

Parameters
vararg elements: LayoutReference

LayoutReferences to be laid out by the Grid helper

orientation: Int = 0

0 if horizontal and 1 if vertical

rows: Int = 0

sets the number of rows in Grid

columns: Int = 0

sets the number of columns in Grid

verticalGap: Dp = 0.dp

defines the gap between views in the y axis

horizontalGap: Dp = 0.dp

defines the gap between views in the x axis

rowWeights: IntArray = intArrayOf()

defines the weight of each row

columnWeights: IntArray = intArrayOf()

defines the weight of each column

skips: Array<Skip> = arrayOf()

defines the positions in a Grid to be skipped the format: Skip(position, rows, columns) position - the index of the starting position rows - the number of rows to skip coloumns - the number of columns to skip

spans: Array<Span> = arrayOf()

defines the spanned area(s) in Grid the format: Span(position, rows, columns) position - the index of the starting position rows - the number of rows to span coloumns - the number of columns to span

padding: Dp = 0.dp

sets padding around the content

flags: Array<GridFlag> = arrayOf()

set different flags to be enabled (not case-sensitive), including SubGridByColRow: reverse the width and height specification for spans/skips. Original - Position:HeightxWidth; with the flag - Position:WidthxHeight SpansRespectWidgetOrder: spans would respect the order of the widgets. Original - the widgets in the front of the widget list would be assigned to the spanned area; with the flag - all the widges will be arranged based on the given order. For example, for a layout with 1 row and 3 columns. If we have two widgets: w1, w2 with a span as 1:1x2, the original layout would be w2 w1 w1. Since w1 is in the front of the list, it would be assigned to the spanned area. With the flag, the layout would be w1 w2 w2 that respects the order of the widget list.

createGrid

fun createGrid(
    vararg elements: LayoutReference,
    orientation: Int = 0,
    rows: Int = 0,
    columns: Int = 0,
    verticalGap: Dp = 0.dp,
    horizontalGap: Dp = 0.dp,
    rowWeights: IntArray = intArrayOf(),
    columnWeights: IntArray = intArrayOf(),
    skips: Array<Skip> = arrayOf(),
    spans: Array<Span> = arrayOf(),
    paddingHorizontal: Dp = 0.dp,
    paddingVertical: Dp = 0.dp,
    flags: Array<GridFlag> = arrayOf()
): ConstrainedLayoutReference

Creates a Grid representation with a Grid Helper. Example: ConstraintLayout( ConstraintSet { val a = createRefFor("1") val b = createRefFor("2") val c = createRefFor("3") val d = createRefFor("4") val e = createRefFor("5") val f = createRefFor("6") val g = createRefFor("7") val h = createRefFor("8") val i = createRefFor("9") val j = createRefFor("0") val k = createRefFor("box") val weights = intArrayOf(3, 3, 2, 2) val flags = arrayOf("SubGridByColRow", "SpansRespectWidgetOrder") val g1 = createGrid( k, a, b, c, d, e, f, g, h, i, j, k, rows = 5, columns = 3, verticalGap = 25.dp, horizontalGap = 25.dp, skips = arrayOf(Skip(12, 1, 1)), spans = arrayOf(Span(0, 1, 3)), rowWeights = weights, paddingHorizontal = 10.dp, paddingVertical = 10.dp, flags = flags, ) constrain(g1) { width = Dimension.matchParent height = Dimension.matchParent }, modifier = Modifier.fillMaxSize() ) { val numArray = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "0") for (num in numArray) { Button( modifier = Modifier.layoutId(num).width(120.dp), onClick = {}, ) { Text(text = String.format("btn%s", num)) } } Box( modifier = Modifier.background(Color.Gray).layoutId("box"), Alignment.BottomEnd ) { Text("100", fontSize = 80.sp) } }

Parameters
vararg elements: LayoutReference

LayoutReferences to be laid out by the Grid helper

orientation: Int = 0

0 if horizontal and 1 if vertical

rows: Int = 0

sets the number of rows in Grid

columns: Int = 0

sets the number of columns in Grid

verticalGap: Dp = 0.dp

defines the gap between views in the y axis

horizontalGap: Dp = 0.dp

defines the gap between views in the x axis

rowWeights: IntArray = intArrayOf()

defines the weight of each row

columnWeights: IntArray = intArrayOf()

defines the weight of each column

skips: Array<Skip> = arrayOf()

defines the positions in a Grid to be skipped the format: Skip(position, rows, columns) position - the index of the starting position rows - the number of rows to skip coloumns - the number of columns to skip

spans: Array<Span> = arrayOf()

defines the spanned area(s) in Grid the format: Span(position, rows, columns) position - the index of the starting position rows - the number of rows to span coloumns - the number of columns to span

paddingHorizontal: Dp = 0.dp

sets paddingStart and paddingEnd of the content

paddingVertical: Dp = 0.dp

sets paddingTop and paddingBottom of the content

flags: Array<GridFlag> = arrayOf()

set different flags to be enabled (not case-sensitive), including SubGridByColRow: reverse the width and height specification for spans/skips. Original - Position:HeightxWidth; with the flag - Position:WidthxHeight SpansRespectWidgetOrder: spans would respect the order of the widgets. Original - the widgets in the front of the widget list would be assigned to the spanned area; with the flag - all the widges will be arranged based on the given order. For example, for a layout with 1 row and 3 columns. If we have two widgets: w1, w2 with a span as 1:1x2, the original layout would be w2 w1 w1. Since w1 is in the front of the list, it would be assigned to the spanned area. With the flag, the layout would be w1 w2 w2 that respects the order of the widget list.

createGrid

fun createGrid(
    vararg elements: LayoutReference,
    orientation: Int = 0,
    rows: Int = 0,
    columns: Int = 0,
    verticalGap: Dp = 0.dp,
    horizontalGap: Dp = 0.dp,
    rowWeights: IntArray = intArrayOf(),
    columnWeights: IntArray = intArrayOf(),
    skips: Array<Skip> = arrayOf(),
    spans: Array<Span> = arrayOf(),
    paddingStart: Dp = 0.dp,
    paddingTop: Dp = 0.dp,
    paddingEnd: Dp = 0.dp,
    paddingBottom: Dp = 0.dp,
    flags: Array<GridFlag> = arrayOf()
): ConstrainedLayoutReference

Creates a Grid representation with a Grid Helper. Example: ConstraintLayout( ConstraintSet { val a = createRefFor("1") val b = createRefFor("2") val c = createRefFor("3") val d = createRefFor("4") val e = createRefFor("5") val f = createRefFor("6") val g = createRefFor("7") val h = createRefFor("8") val i = createRefFor("9") val j = createRefFor("0") val k = createRefFor("box") val weights = intArrayOf(3, 3, 2, 2) val flags = arrayOf("SubGridByColRow", "SpansRespectWidgetOrder") val g1 = createGrid( k, a, b, c, d, e, f, g, h, i, j, k, rows = 5, columns = 3, verticalGap = 25.dp, horizontalGap = 25.dp, skips = arrayOf(Skip(12, 1, 1)), spans = arrayOf(Span(0, 1, 3)), rowWeights = weights, paddingStart = 10.dp, paddingTop = 10.dp, paddingEnd = 10.dp, paddingBottom = 10.dp, flags = flags, ) constrain(g1) { width = Dimension.matchParent height = Dimension.matchParent }, modifier = Modifier.fillMaxSize() ) { val numArray = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "0") for (num in numArray) { Button( modifier = Modifier.layoutId(num).width(120.dp), onClick = {}, ) { Text(text = String.format("btn%s", num)) } } Box( modifier = Modifier.background(Color.Gray).layoutId("box"), Alignment.BottomEnd ) { Text("100", fontSize = 80.sp) } }

Parameters
vararg elements: LayoutReference

LayoutReferences to be laid out by the Grid helper

orientation: Int = 0

0 if horizontal and 1 if vertical

rows: Int = 0

sets the number of rows in Grid

columns: Int = 0

sets the number of columns in Grid

verticalGap: Dp = 0.dp

defines the gap between views in the y axis

horizontalGap: Dp = 0.dp

defines the gap between views in the x axis

rowWeights: IntArray = intArrayOf()

defines the weight of each row

columnWeights: IntArray = intArrayOf()

defines the weight of each column

skips: Array<Skip> = arrayOf()

defines the positions in a Grid to be skipped the format: Skip(position, rows, columns) position - the index of the starting position rows - the number of rows to skip coloumns - the number of columns to skip

spans: Array<Span> = arrayOf()

defines the spanned area(s) in Grid the format: Span(position, rows, columns) position - the index of the starting position rows - the number of rows to span coloumns - the number of columns to span

paddingStart: Dp = 0.dp

sets paddingStart of the content

paddingTop: Dp = 0.dp

sets paddingTop of the content

paddingEnd: Dp = 0.dp

sets paddingEnd of the content

paddingBottom: Dp = 0.dp

sets paddingBottom of the content

flags: Array<GridFlag> = arrayOf()

set different flags to be enabled (not case-sensitive), including SubGridByColRow: reverse the width and height specification for spans/skips. Original - Position:HeightxWidth; with the flag - Position:WidthxHeight SpansRespectWidgetOrder: spans would respect the order of the widgets. Original - the widgets in the front of the widget list would be assigned to the spanned area; with the flag - all the widges will be arranged based on the given order. For example, for a layout with 1 row and 3 columns. If we have two widgets: w1, w2 with a span as 1:1x2, the original layout would be w2 w1 w1. Since w1 is in the front of the list, it would be assigned to the spanned area. With the flag, the layout would be w1 w2 w2 that respects the order of the widget list.

createGuidelineFromAbsoluteLeft

Added in 1.1.0-alpha13
fun createGuidelineFromAbsoluteLeft(fraction: Float): ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a width fraction from the left of the ConstraintLayout. A fraction of 0f will correspond to the left of the ConstraintLayout, while 1f will correspond to the right.

createGuidelineFromAbsoluteLeft

fun createGuidelineFromAbsoluteLeft(offset: Dp): ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the left of the ConstraintLayout.

createGuidelineFromAbsoluteRight

Added in 1.1.0-alpha13
fun createGuidelineFromAbsoluteRight(fraction: Float): ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a width fraction from the right of the ConstraintLayout. A fraction of 0f will correspond to the right of the ConstraintLayout, while 1f will correspond to the left.

createGuidelineFromAbsoluteRight

fun createGuidelineFromAbsoluteRight(offset: Dp): ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the right of the ConstraintLayout.

createGuidelineFromBottom

Added in 1.1.0-alpha13
fun createGuidelineFromBottom(fraction: Float): ConstraintLayoutBaseScope.HorizontalAnchor

Creates a guideline at a height percentage from the bottom of the ConstraintLayout. A fraction of 0f will correspond to the bottom of the ConstraintLayout, while 1f will correspond to the top.

createGuidelineFromBottom

fun createGuidelineFromBottom(offset: Dp): ConstraintLayoutBaseScope.HorizontalAnchor

Creates a guideline at a specific offset from the bottom of the ConstraintLayout.

createGuidelineFromEnd

Added in 1.1.0-alpha13
fun createGuidelineFromEnd(fraction: Float): ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a width fraction from the end of the ConstraintLayout. A fraction of 0f will correspond to the end of the ConstraintLayout, while 1f will correspond to the start.

createGuidelineFromEnd

fun createGuidelineFromEnd(offset: Dp): ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the end of the ConstraintLayout.

createGuidelineFromStart

Added in 1.1.0-alpha13
fun createGuidelineFromStart(fraction: Float): ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the start of the ConstraintLayout. A fraction of 0f will correspond to the start of the ConstraintLayout, while 1f will correspond to the end.

createGuidelineFromStart

fun createGuidelineFromStart(offset: Dp): ConstraintLayoutBaseScope.VerticalAnchor

Creates a guideline at a specific offset from the start of the ConstraintLayout.

createGuidelineFromTop

Added in 1.1.0-alpha13
fun createGuidelineFromTop(fraction: Float): ConstraintLayoutBaseScope.HorizontalAnchor

Creates a guideline at a height fraction from the top of the ConstraintLayout. A fraction of 0f will correspond to the top of the ConstraintLayout, while 1f will correspond to the bottom.

createGuidelineFromTop

fun createGuidelineFromTop(offset: Dp): ConstraintLayoutBaseScope.HorizontalAnchor

Creates a guideline at a specific offset from the top of the ConstraintLayout.

createHorizontalChain

fun createHorizontalChain(
    vararg elements: LayoutReference,
    chainStyle: ChainStyle = ChainStyle.Spread
): HorizontalChainReference

Creates a horizontal chain including the referenced layouts.

Use constrain with the resulting HorizontalChainReference to modify the start/left and end/right constraints of this chain.

createRow

fun createRow(
    vararg elements: LayoutReference,
    skips: Array<Skip> = arrayOf(),
    spans: Array<Span> = arrayOf(),
    horizontalGap: Dp = 0.dp,
    columnWeights: IntArray = intArrayOf(),
    padding: Dp = 0.dp
): ConstrainedLayoutReference

Creates a Grid based helper that lays out its elements in a single Row. Example: ConstraintLayout( ConstraintSet { val a = createRefFor("1") val b = createRefFor("2") val c = createRefFor("3") val d = createRefFor("4") val e = createRefFor("5") val weights = intArrayOf(3, 3, 2, 2, 1) val g1 = createRow( a, b, c, d, e, skips = arrayOf(Skip(1, 1), Skip(3, 2)), spans = arrayOf(Span(1, 2)), horizontalGap = 10.dp, columnWeights = weights, padding = 10.dp, ) constrain(g1) { width = Dimension.matchParent height = Dimension.matchParent }, modifier = Modifier.fillMaxSize() ) { val numArray = arrayOf("1", "2", "3", "4", "5") for (num in numArray) { Button( modifier = Modifier.layoutId(num).width(120.dp), onClick = {}, ) { Text(text = String.format("btn%s", num)) } } }

Parameters
vararg elements: LayoutReference

LayoutReferences to be laid out by the Grid helper

skips: Array<Skip> = arrayOf()

specify area(s) in a Row to be skipped - format: Skip(index, size)

spans: Array<Span> = arrayOf()

specify area(s) in a Row to be spanned - format: Span(index, size)

horizontalGap: Dp = 0.dp

defines the gap between views in the x axis

columnWeights: IntArray = intArrayOf()

defines the weight of each column

padding: Dp = 0.dp

sets padding around the content

createRow

fun createRow(
    vararg elements: LayoutReference,
    skips: Array<Skip> = arrayOf(),
    spans: Array<Span> = arrayOf(),
    horizontalGap: Dp = 0.dp,
    columnWeights: IntArray = intArrayOf(),
    paddingHorizontal: Dp = 0.dp,
    paddingVertical: Dp = 0.dp
): ConstrainedLayoutReference

Creates a Grid based helper that lays out its elements in a single Row. Example: ConstraintLayout( ConstraintSet { val a = createRefFor("1") val b = createRefFor("2") val c = createRefFor("3") val d = createRefFor("4") val e = createRefFor("5") val weights = intArrayOf(3, 3, 2, 2, 1) val g1 = createRow( a, b, c, d, e, skips = arrayOf(Skip(1, 1), Skip(3, 2)), spans = arrayOf(Span(1, 2)), horizontalGap = 10.dp, columnWeights = weights, paddingHorizontal = 10.dp, paddingVertical = 10.dp, ) constrain(g1) { width = Dimension.matchParent height = Dimension.matchParent }, modifier = Modifier.fillMaxSize() ) { val numArray = arrayOf("1", "2", "3", "4", "5") for (num in numArray) { Button( modifier = Modifier.layoutId(num).width(120.dp), onClick = {}, ) { Text(text = String.format("btn%s", num)) } } }

Parameters
vararg elements: LayoutReference

LayoutReferences to be laid out by the Grid helper

skips: Array<Skip> = arrayOf()

specify area(s) in a Row to be skipped - format: Skip(index, size)

spans: Array<Span> = arrayOf()

specify area(s) in a Row to be spanned - format: Span(index, size)

horizontalGap: Dp = 0.dp

defines the gap between views in the y axis

columnWeights: IntArray = intArrayOf()

defines the weight of each column

paddingHorizontal: Dp = 0.dp

sets paddingStart and paddingEnd of the content

paddingVertical: Dp = 0.dp

sets paddingTop and paddingBottom of the content

createStartBarrier

fun createStartBarrier(vararg elements: LayoutReference, margin: Dp = 0.dp): ConstraintLayoutBaseScope.VerticalAnchor

Creates and returns a start barrier, containing the specified elements.

createTopBarrier

fun createTopBarrier(vararg elements: LayoutReference, margin: Dp = 0.dp): ConstraintLayoutBaseScope.HorizontalAnchor

Creates and returns a top barrier, containing the specified elements.

createVerticalChain

fun createVerticalChain(
    vararg elements: LayoutReference,
    chainStyle: ChainStyle = ChainStyle.Spread
): VerticalChainReference

Creates a vertical chain including the referenced layouts.

Use constrain with the resulting VerticalChainReference to modify the top and bottom constraints of this chain.

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

reset

Added in 1.1.0-alpha13
open fun reset(): Unit
fun LayoutReference.withChainParams(
    startMargin: Dp = 0.dp,
    topMargin: Dp = 0.dp,
    endMargin: Dp = 0.dp,
    bottomMargin: Dp = 0.dp,
    startGoneMargin: Dp = 0.dp,
    topGoneMargin: Dp = 0.dp,
    endGoneMargin: Dp = 0.dp,
    bottomGoneMargin: Dp = 0.dp,
    weight: Float = Float.NaN
): LayoutReference

Sets the parameters that are used by chains to customize the resulting layout.

Use margins to customize the space between widgets in the chain.

Use weight to distribute available space to each widget when their dimensions are not fixed.

 

Similarly named parameters available from ConstrainScope.linkTo are ignored in Chains.

Since margins are only for widgets within the chain: Top, Start and End, Bottom margins are ignored when the widget is the first or the last element in the chain, respectively.

Parameters
startMargin: Dp = 0.dp

Added space from the start of this widget to the previous widget

topMargin: Dp = 0.dp

Added space from the top of this widget to the previous widget

endMargin: Dp = 0.dp

Added space from the end of this widget to the next widget

bottomMargin: Dp = 0.dp

Added space from the bottom of this widget to the next widget

startGoneMargin: Dp = 0.dp

Added space from the start of this widget when the previous widget has Visibility.Gone

topGoneMargin: Dp = 0.dp

Added space from the top of this widget when the previous widget has Visibility.Gone

endGoneMargin: Dp = 0.dp

Added space from the end of this widget when the next widget has Visibility.Gone

bottomGoneMargin: Dp = 0.dp

Added space from the bottom of this widget when the next widget has Visibility.Gone

weight: Float = Float.NaN

Defines the proportion of space (relative to the total weight) occupied by this layout when the corresponding dimension is not a fixed value.

Returns
LayoutReference

The same LayoutReference instance with the applied values

fun LayoutReference.withHorizontalChainParams(
    startMargin: Dp = 0.dp,
    endMargin: Dp = 0.dp,
    startGoneMargin: Dp = 0.dp,
    endGoneMargin: Dp = 0.dp,
    weight: Float = Float.NaN
): LayoutReference

Sets the parameters that are used by horizontal chains to customize the resulting layout.

Use margins to customize the space between widgets in the chain.

Use weight to distribute available space to each widget when their horizontal dimension is not fixed.

 

Similarly named parameters available from ConstrainScope.linkTo are ignored in Chains.

Since margins are only for widgets within the chain: Start and End margins are ignored when the widget is the first or the last element in the chain, respectively.

Parameters
startMargin: Dp = 0.dp

Added space from the start of this widget to the previous widget

endMargin: Dp = 0.dp

Added space from the end of this widget to the next widget

startGoneMargin: Dp = 0.dp

Added space from the start of this widget when the previous widget has Visibility.Gone

endGoneMargin: Dp = 0.dp

Added space from the end of this widget when the next widget has Visibility.Gone

weight: Float = Float.NaN

Defines the proportion of space (relative to the total weight) occupied by this layout when the width is not a fixed dimension.

Returns
LayoutReference

The same LayoutReference instance with the applied values

fun LayoutReference.withVerticalChainParams(
    topMargin: Dp = 0.dp,
    bottomMargin: Dp = 0.dp,
    topGoneMargin: Dp = 0.dp,
    bottomGoneMargin: Dp = 0.dp,
    weight: Float = Float.NaN
): LayoutReference

Sets the parameters that are used by vertical chains to customize the resulting layout.

Use margins to customize the space between widgets in the chain.

Use weight to distribute available space to each widget when their vertical dimension is not fixed.

 

Similarly named parameters available from ConstrainScope.linkTo are ignored in Chains.

Since margins are only for widgets within the chain: Top and Bottom margins are ignored when the widget is the first or the last element in the chain, respectively.

Parameters
topMargin: Dp = 0.dp

Added space from the top of this widget to the previous widget

bottomMargin: Dp = 0.dp

Added space from the bottom of this widget to the next widget

topGoneMargin: Dp = 0.dp

Added space from the top of this widget when the previous widget has Visibility.Gone

bottomGoneMargin: Dp = 0.dp

Added space from the bottom of this widget when the next widget has Visibility.Gone

weight: Float = Float.NaN

Defines the proportion of space (relative to the total weight) occupied by this layout when the height is not a fixed dimension.

Returns
LayoutReference

The same LayoutReference instance with the applied values

Protected properties

tasks

Added in 1.1.0-alpha13
Deprecated in 1.1.0-alpha13
protected val tasksMutableList<(State) -> Unit>