ConstraintLayout

abstract class ConstraintLayout : Layout

A Layout that positions Views using a set of constraints. These layouts are created using the constrain functions and follow the form:

val layout = constrain(view1, view2) { v1, v2 ->
v1.left eq 10
v1.width lessEq parent.width / 2

v2.edges eq parent.edges - 10
}

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Notified whenever an unhandled ConstraintException is thrown during layout.

Functions

Link copied to clipboard
abstract fun constrain(view: View, constraints: ConstraintDslContext.(Bounds) -> Unit): ConstraintLayout

Add constraints for view.

abstract fun constrain(first: View, second: View, constraints: ConstraintDslContext.(Bounds, Bounds) -> Unit): ConstraintLayout

Add constraints for 2 Views.

abstract fun constrain(first: View, second: View, third: View, constraints: ConstraintDslContext.(Bounds, Bounds, Bounds) -> Unit): ConstraintLayout

Add constraints for 3 Views.

abstract fun constrain(first: View, second: View, vararg others: View, constraints: ConstraintDslContext.(List<Bounds>) -> Unit): ConstraintLayout

Add constraints for several Views.

abstract fun constrain(first: View, second: View, third: View, fourth: View, constraints: ConstraintDslContext.(Bounds, Bounds, Bounds, Bounds) -> Unit): ConstraintLayout

Add constraints for 4 Views.

abstract fun constrain(first: View, second: View, third: View, fourth: View, fifth: View, constraints: ConstraintDslContext.(Bounds, Bounds, Bounds, Bounds, Bounds) -> Unit): ConstraintLayout

Add constraints for 5 Views.

Link copied to clipboard
abstract fun unconstrain(view: View, constraints: ConstraintDslContext.(Bounds) -> Unit): ConstraintLayout

Remove all constraints for view that were created by constraints.

abstract fun unconstrain(first: View, second: View, constraints: ConstraintDslContext.(Bounds, Bounds) -> Unit): ConstraintLayout
abstract fun unconstrain(first: View, second: View, third: View, constraints: ConstraintDslContext.(Bounds, Bounds, Bounds) -> Unit): ConstraintLayout
abstract fun unconstrain(first: View, second: View, vararg others: View, constraints: ConstraintDslContext.(List<Bounds>) -> Unit): ConstraintLayout
abstract fun unconstrain(first: View, second: View, third: View, fourth: View, constraints: ConstraintDslContext.(Bounds, Bounds, Bounds, Bounds) -> Unit): ConstraintLayout
abstract fun unconstrain(first: View, second: View, third: View, fourth: View, fifth: View, constraints: ConstraintDslContext.(Bounds, Bounds, Bounds, Bounds, Bounds) -> Unit): ConstraintLayout

Remove all constraints for the given Views that were created by constraints.

Inherited functions

Link copied to clipboard

Gets the child within the Positionable at the given point. The default is to ignore these calls and let the caller perform their own search for the right child. But Layouts are free to return a value here if it can be done more efficiently.

Link copied to clipboard
open fun idealSize(container: PositionableContainer, default: Size? = null): Size?

Returns the ideal size of the Positionable based on its contents.

Link copied to clipboard
abstract fun layout(container: PositionableContainer)

Lays out the children of the given Positionable.

Link copied to clipboard
open fun minimumSize(container: PositionableContainer, default: Size = Empty): Size

Returns the minimum size of the Positionable based on its contents.

Link copied to clipboard
open fun requiresLayout(container: PositionableContainer, old: Size, new: Size): Boolean

Indicates whether a layout is needed because of the given size change to the Container. This is called whenever the container's size changes.

Indicates whether a layout is needed because of the given size preferences change to a child of the given Container. This is called whenever the container's size changes.

Indicates whether a layout is needed because of the given bounds change to a child of the given Container. This is called whenever the container's size changes.

Link copied to clipboard
infix fun Layout.then(onLayout: (PositionableContainer) -> Unit): Layout

Provides a way to get notified each time a Layout is done positioning.