class ConstraintWidget

Known direct subclasses
Guideline

Guideline

HelperWidget

HelperWidget class

WidgetContainer

A container of ConstraintWidget

Known indirect subclasses
Barrier

A Barrier takes multiple widgets

ConstraintWidgetContainer

A container of ConstraintWidget that can layout its children

Flow

Implements the Flow virtual layout.

GridCore

The Grid Helper in the Core library that helps to enable Grid in Compose

Placeholder

Simple VirtualLayout that center the first referenced widget onto itself.

VirtualLayout

Base class for Virtual layouts


Implements a constraint Widget model supporting constraints relations between other widgets.

The widget has various anchors (i.e. Left, Top, Right, Bottom, representing their respective sides, as well as Baseline, Center_X and Center_Y). Connecting anchors from one widget to another represents a constraint relation between the two anchors; the LinearSystem will then be able to use this model to try to minimize the distances between connected anchors.

If opposite anchors are connected (e.g. Left and Right anchors), if they have the same strength, the widget will be equally pulled toward their respective target anchor positions; if the widget has a fixed size, this means that the widget will be centered between the two target anchors. If the widget's size is allowed to adjust, the size of the widget will change to be as large as necessary so that the widget's anchors and the target anchors' distances are zero.

Constraints are set by connecting a widget's anchor to another via the connect function.

Summary

Nested types

Define how the widget will resize

Constants

const Int
const Int
const Int
const Int
const Int
const Int
BOTH = 2
const Int
const Int
const Int
const Int
DIRECT = 2
const Int
GONE = 8
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
SOLVER = 1
const Int
UNKNOWN = -1
const Int
const Int
const Int
const Int
const Int
const Int

Public constructors

Default constructor

ConstraintWidget(debugName: String!)
ConstraintWidget(width: Int, height: Int)

Constructor

ConstraintWidget(debugName: String!, width: Int, height: Int)
ConstraintWidget(x: Int, y: Int, width: Int, height: Int)

Constructor

ConstraintWidget(debugName: String!, x: Int, y: Int, width: Int, height: Int)

Public functions

Unit
addChildrenToSolverByDependency(
    container: ConstraintWidgetContainer!,
    system: LinearSystem!,
    widgets: HashSet<ConstraintWidget!>!,
    orientation: Int,
    addSelf: Boolean
)
Unit
addToSolver(system: LinearSystem!, optimize: Boolean)

Add this widget to the solver

Boolean

Returns true if this widget should be used in a barrier

Unit
connect(
    constraintFrom: ConstraintAnchor.Type!,
    target: ConstraintWidget!,
    constraintTo: ConstraintAnchor.Type!
)

Connect a given anchor of this widget to another anchor of a target widget

Unit
connect(from: ConstraintAnchor!, to: ConstraintAnchor!, margin: Int)

Connect the given anchors together (the from anchor should be owned by this widget)

Unit
connect(
    constraintFrom: ConstraintAnchor.Type!,
    target: ConstraintWidget!,
    constraintTo: ConstraintAnchor.Type!,
    margin: Int
)

Connect a given anchor of this widget to another anchor of a target widget

Unit
connectCircularConstraint(
    target: ConstraintWidget!,
    angle: Float,
    radius: Int
)

Set a circular constraint

Unit
copy(
    src: ConstraintWidget!,
    map: HashMap<ConstraintWidget!, ConstraintWidget!>!
)
Unit

Create all the system variables for this widget

Unit
Unit
ConstraintAnchor!

Given a type of anchor, returns the corresponding anchor.

ArrayList<ConstraintAnchor!>!

Return the array of anchors of this widget

Int

Return the baseline distance relative to the top of the widget

Float
getBiasPercent(orientation: Int)

Return the percentage bias that is used when two opposite connections exist of the same strength in a particular orientation.

Int

Return the bottom position of the widget

Any!

Return the companion widget.

Int

Accessor for the skip value

String!

Returns the name of this widget (used for debug purposes)

ConstraintWidget.DimensionBehaviour!
getDimensionBehaviour(orientation: Int)

Get the widget's DimensionBehaviour in an specific orientation.

Float

Return the current ratio of this widget

Int

Return the current side on which ratio will be applied

Boolean
Int

Return the height of the widget

Float

Return the horizontal percentage bias that is used when two opposite connections exist of the same strength.

ConstraintWidget!

if in a horizontal chain return the left most widget in the chain.

Int

get the chain starting from this widget to be packed.

ConstraintWidget.DimensionBehaviour!

Accessor for the horizontal dimension behaviour

Int

Returns all the horizontal margin of the widget.

Int
Int
Int

Return the left position of the widget (similar to getX)

Int
getLength(orientation: Int)

Get a dimension of the widget in a particular orientation.

Int
Int
Int

Return the minimum height of the widget

Int

Return the minimum width of the widget

ConstraintWidget!
getNextChainMember(orientation: Int)

Return the next chain member if one exists

Int
Int
ConstraintWidget!

Returns the parent of this widget if there is one

ConstraintWidget!

Return the previous chain member if one exists

Int

Return the right position of the widget

WidgetRun!
getRun(orientation: Int)
Unit
Int

Return the top position of the widget (similar to getY)

String!

Returns the type string if set

Float

Return the vertical percentage bias that is used when two opposite connections exist of the same strength.

ConstraintWidget!

if in a vertical chain return the top most widget in the chain.

Int

Set the chain starting from this widget to be packed.

ConstraintWidget.DimensionBehaviour!

Accessor for the vertical dimension behaviour

Int

Returns all the vertical margin of the widget

Int

Returns the current visibility value for this widget

Int

Return the width of the widget

Int
Int

Return the x position of the widget, relative to its container

Int

Return the y position of the widget, relative to its container

Boolean

Return true if this widget has a baseline

Boolean
hasDanglingDimension(orientation: Int)
Boolean
Boolean
Boolean
hasResolvedTargets(orientation: Int, size: Int)
Unit
immediateConnect(
    startType: ConstraintAnchor.Type!,
    target: ConstraintWidget!,
    endType: ConstraintAnchor.Type!,
    margin: Int,
    goneMargin: Int
)

Immediate connection to an anchor without any checks.

Boolean

Returns if this widget is animated.

Boolean

Returns true if height is set to wrap_content

Boolean
Boolean
isInBarrier(orientation: Int)
Boolean

Test if you are in a Horizontal chain

Boolean
Boolean

Test if you are in a vertical chain

Boolean
Boolean
Boolean
Boolean
Boolean

Returns true if the widget is the root widget

Boolean
Boolean
Boolean
Boolean

Returns true if width is set to wrap_content

Unit
Unit
Boolean
Boolean
Unit
Unit

Reset all the constraints set on this widget

Unit

Reset the given anchor

Unit

Reset all connections

Unit
Unit

Reset the solver variables of the anchors

Unit
StringBuilder!

Serialize the anchors for JSON5 output

Unit
setAnimated(animated: Boolean)

Set if this widget is animated.

Unit

Set the baseline distance relative to the top of the widget

Unit
setCompanionWidget(companion: Any!)

Set the companion widget.

Unit

Set the skip value for this widget.

Unit

Set the debug name of this widget

Unit

Utility debug function.

Unit
setDimension(w: Int, h: Int)

Set both width and height of the widget

Unit

Set the ratio of the widget

Unit
setDimensionRatio(ratio: Float, dimensionRatioSide: Int)

Set the ratio of the widget The ratio will be applied if at least one of the dimension (width or height) is set to a behaviour of DimensionBehaviour.MATCH_CONSTRAINT -- the dimension's value will be set to the other dimension * ratio.

Unit
setFinalBaseline(baselineValue: Int)
Unit
setFinalFrame(
    left: Int,
    top: Int,
    right: Int,
    bottom: Int,
    baseline: Int,
    orientation: Int
)
Unit
Unit
Unit
Unit
setFinalVertical(y1: Int, y2: Int)
Unit
setFrame(start: Int, end: Int, orientation: Int)

Set the position+dimension of the widget based on starting/ending positions on one dimension.

Unit
setFrame(left: Int, top: Int, right: Int, bottom: Int)

Set the position+dimension of the widget given left/top/right/bottom

Unit
setGoneMargin(type: ConstraintAnchor.Type!, goneMargin: Int)

Set the margin to be used when connected to a widget with a visibility of GONE

Unit
setHasBaseline(hasBaseline: Boolean)
Unit

Set the height of the widget

Unit
setHeightWrapContent(heightWrapContent: Boolean)

Keep track of wrap_content for height

Unit
setHorizontalBiasPercent(horizontalBiasPercent: Float)

Set the horizontal bias percent to apply when we have two opposite constraints of equal strength

Unit
setHorizontalChainStyle(horizontalChainStyle: Int)

Set the chain starting from this widget to be packed.

Unit
setHorizontalDimension(left: Int, right: Int)

Set the positions for the horizontal dimension only

Unit

Set the widget's behaviour for the horizontal dimension

Unit
setHorizontalMatchStyle(
    horizontalMatchStyle: Int,
    min: Int,
    max: Int,
    percent: Float
)

Set the horizontal style when MATCH_CONSTRAINT is set

Unit
setHorizontalWeight(horizontalWeight: Float)

Set the horizontal weight (only used in chains)

Unit
setInPlaceholder(inPlaceholder: Boolean)
Unit
setInVirtualLayout(inVirtualLayout: Boolean)
Unit
setLastMeasureSpec(horizontal: Int, vertical: Int)
Unit
setLength(length: Int, orientation: Int)

Set the dimension of a widget in a particular orientation.

Unit
setMaxHeight(maxHeight: Int)
Unit
setMaxWidth(maxWidth: Int)
Unit
setMeasureRequested(measureRequested: Boolean)
Unit

Set the minimum height of the widget

Unit

Set the minimum width of the widget

Unit
setOffset(x: Int, y: Int)

Set the offset of this widget relative to the root widget

Unit
setOrigin(x: Int, y: Int)

Set both the origin in (x, y) of the widget, relative to its container

Unit

Set the parent of this widget

Unit
setType(type: String!)

Set the type of the widget (as a String)

Unit
setVerticalBiasPercent(verticalBiasPercent: Float)

Set the vertical bias percent to apply when we have two opposite constraints of equal strength

Unit
setVerticalChainStyle(verticalChainStyle: Int)

Set the chain starting from this widget to be packed.

Unit
setVerticalDimension(top: Int, bottom: Int)

Set the positions for the vertical dimension only

Unit

Set the widget's behaviour for the vertical dimension

Unit
setVerticalMatchStyle(
    verticalMatchStyle: Int,
    min: Int,
    max: Int,
    percent: Float
)

Set the vertical style when MATCH_CONSTRAINT is set

Unit
setVerticalWeight(verticalWeight: Float)

Set the vertical weight (only used in chains)

Unit
setVisibility(visibility: Int)

Set the visibility for this widget

Unit

Set the width of the widget

Unit
setWidthWrapContent(widthWrapContent: Boolean)

Keep track of wrap_content for width

Unit
Unit
setX(x: Int)

Set the x position of the widget, relative to its container

Unit
setY(y: Int)

Set the y position of the widget, relative to its container

Unit
setupDimensionRatio(
    hParentWrapContent: Boolean,
    vParentWrapContent: Boolean,
    horizontalDimensionFixed: Boolean,
    verticalDimensionFixed: Boolean
)

Resolves the dimension ratio parameters (mResolvedDimensionRatioSide &mDimensionRatio)

String!

Returns a string representation of the ConstraintWidget

Unit
updateFromRuns(updateHorizontal: Boolean, updateVertical: Boolean)
Unit
updateFromSolver(system: LinearSystem!, optimize: Boolean)

Update the widget from the values generated by the solver

Protected functions

Int

Return the x position of the widget, relative to the root (without animation)

Int

Return the y position of the widget, relative to the root (without animation)

Unit
setInBarrier(orientation: Int, value: Boolean)

Constants

ANCHOR_BASELINE

Added in 1.1.0
const val ANCHOR_BASELINE = 4: Int

ANCHOR_BOTTOM

Added in 1.1.0
const val ANCHOR_BOTTOM = 3: Int

ANCHOR_LEFT

Added in 1.1.0
const val ANCHOR_LEFT = 0: Int

ANCHOR_RIGHT

Added in 1.1.0
const val ANCHOR_RIGHT = 1: Int

ANCHOR_TOP

Added in 1.1.0
const val ANCHOR_TOP = 2: Int

BOTH

Added in 1.1.0
const val BOTH = 2: Int

CHAIN_PACKED

Added in 1.1.0
const val CHAIN_PACKED = 2: Int

CHAIN_SPREAD

Added in 1.1.0
const val CHAIN_SPREAD = 0: Int

CHAIN_SPREAD_INSIDE

Added in 1.1.0
const val CHAIN_SPREAD_INSIDE = 1: Int

DIRECT

Added in 1.1.0
protected const val DIRECT = 2: Int

GONE

Added in 1.1.0
const val GONE = 8: Int

HORIZONTAL

Added in 1.1.0
const val HORIZONTAL = 0: Int

INVISIBLE

Added in 1.1.0
const val INVISIBLE = 4: Int

MATCH_CONSTRAINT_PERCENT

Added in 1.1.0
const val MATCH_CONSTRAINT_PERCENT = 2: Int

MATCH_CONSTRAINT_RATIO

Added in 1.1.0
const val MATCH_CONSTRAINT_RATIO = 3: Int

MATCH_CONSTRAINT_RATIO_RESOLVED

Added in 1.1.0
const val MATCH_CONSTRAINT_RATIO_RESOLVED = 4: Int

MATCH_CONSTRAINT_SPREAD

Added in 1.1.0
const val MATCH_CONSTRAINT_SPREAD = 0: Int

MATCH_CONSTRAINT_WRAP

Added in 1.1.0
const val MATCH_CONSTRAINT_WRAP = 1: Int

SOLVER

Added in 1.1.0
protected const val SOLVER = 1: Int

UNKNOWN

Added in 1.1.0
const val UNKNOWN = -1: Int

VERTICAL

Added in 1.1.0
const val VERTICAL = 1: Int

VISIBLE

Added in 1.1.0
const val VISIBLE = 0: Int

WRAP_BEHAVIOR_HORIZONTAL_ONLY

Added in 1.1.0
const val WRAP_BEHAVIOR_HORIZONTAL_ONLY = 1: Int

WRAP_BEHAVIOR_INCLUDED

Added in 1.1.0
const val WRAP_BEHAVIOR_INCLUDED = 0: Int

WRAP_BEHAVIOR_SKIPPED

Added in 1.1.0
const val WRAP_BEHAVIOR_SKIPPED = 3: Int

WRAP_BEHAVIOR_VERTICAL_ONLY

Added in 1.1.0
const val WRAP_BEHAVIOR_VERTICAL_ONLY = 2: Int

Public constructors

ConstraintWidget

Added in 1.1.0
ConstraintWidget()

Default constructor

ConstraintWidget

Added in 1.1.0
ConstraintWidget(debugName: String!)

ConstraintWidget

Added in 1.1.0
ConstraintWidget(width: Int, height: Int)

Constructor

Parameters
width: Int

width of the layout

height: Int

height of the layout

ConstraintWidget

Added in 1.1.0
ConstraintWidget(debugName: String!, width: Int, height: Int)

ConstraintWidget

Added in 1.1.0
ConstraintWidget(x: Int, y: Int, width: Int, height: Int)

Constructor

Parameters
x: Int

x position

y: Int

y position

width: Int

width of the layout

height: Int

height of the layout

ConstraintWidget

Added in 1.1.0
ConstraintWidget(debugName: String!, x: Int, y: Int, width: Int, height: Int)

Public functions

addChildrenToSolverByDependency

Added in 1.1.0
fun addChildrenToSolverByDependency(
    container: ConstraintWidgetContainer!,
    system: LinearSystem!,
    widgets: HashSet<ConstraintWidget!>!,
    orientation: Int,
    addSelf: Boolean
): Unit

addToSolver

Added in 1.1.0
fun addToSolver(system: LinearSystem!, optimize: Boolean): Unit

Add this widget to the solver

Parameters
system: LinearSystem!

the solver we want to add the widget to

optimize: Boolean

true if OPTIMIZATION_GRAPH is on

allowedInBarrier

Added in 1.1.0
fun allowedInBarrier(): Boolean

Returns true if this widget should be used in a barrier

connect

Added in 1.1.0
fun connect(
    constraintFrom: ConstraintAnchor.Type!,
    target: ConstraintWidget!,
    constraintTo: ConstraintAnchor.Type!
): Unit

Connect a given anchor of this widget to another anchor of a target widget

Parameters
constraintFrom: ConstraintAnchor.Type!

which anchor of this widget to connect from

target: ConstraintWidget!

the target widget

constraintTo: ConstraintAnchor.Type!

the target anchor on the target widget

connect

Added in 1.1.0
fun connect(from: ConstraintAnchor!, to: ConstraintAnchor!, margin: Int): Unit

Connect the given anchors together (the from anchor should be owned by this widget)

Parameters
from: ConstraintAnchor!

the anchor we are connecting from (of this widget)

to: ConstraintAnchor!

the anchor we are connecting to

margin: Int

how much margin we want to have

connect

Added in 1.1.0
fun connect(
    constraintFrom: ConstraintAnchor.Type!,
    target: ConstraintWidget!,
    constraintTo: ConstraintAnchor.Type!,
    margin: Int
): Unit

Connect a given anchor of this widget to another anchor of a target widget

Parameters
constraintFrom: ConstraintAnchor.Type!

which anchor of this widget to connect from

target: ConstraintWidget!

the target widget

constraintTo: ConstraintAnchor.Type!

the target anchor on the target widget

margin: Int

how much margin we want to keep as a minimum distance between the two anchors

connectCircularConstraint

Added in 1.1.0
fun connectCircularConstraint(
    target: ConstraintWidget!,
    angle: Float,
    radius: Int
): Unit

Set a circular constraint

Parameters
target: ConstraintWidget!

the target widget we will use as the center of the circle

angle: Float

the angle (from 0 to 360)

radius: Int

the radius used

copy

Added in 1.1.0
fun copy(
    src: ConstraintWidget!,
    map: HashMap<ConstraintWidget!, ConstraintWidget!>!
): Unit

createObjectVariables

Added in 1.1.0
fun createObjectVariables(system: LinearSystem!): Unit

Create all the system variables for this widget

ensureMeasureRequested

Added in 1.1.0
fun ensureMeasureRequested(): Unit

ensureWidgetRuns

Added in 1.1.0
fun ensureWidgetRuns(): Unit

getAnchor

Added in 1.1.0
fun getAnchor(anchorType: ConstraintAnchor.Type!): ConstraintAnchor!

Given a type of anchor, returns the corresponding anchor.

Parameters
anchorType: ConstraintAnchor.Type!

type of the anchor (LEFT, TOP, RIGHT, BOTTOM, BASELINE, CENTER_X, CENTER_Y)

Returns
ConstraintAnchor!

the matching anchor

getAnchors

Added in 1.1.0
fun getAnchors(): ArrayList<ConstraintAnchor!>!

Return the array of anchors of this widget

Returns
ArrayList<ConstraintAnchor!>!

array of anchors

getBaselineDistance

Added in 1.1.0
fun getBaselineDistance(): Int

Return the baseline distance relative to the top of the widget

Returns
Int

baseline

getBiasPercent

Added in 1.1.0
fun getBiasPercent(orientation: Int): Float

Return the percentage bias that is used when two opposite connections exist of the same strength in a particular orientation.

Parameters
orientation: Int

Orientation HORIZONTAL/VERTICAL.

Returns
Float

Respective percentage bias.

getBottom

Added in 1.1.0
fun getBottom(): Int

Return the bottom position of the widget

Returns
Int

bottom position of the widget

getCompanionWidget

Added in 1.1.0
fun getCompanionWidget(): Any!

Return the companion widget. Typically, this would be the real widget we represent with this instance of ConstraintWidget.

Returns
Any!

the companion widget, if set.

getContainerItemSkip

Added in 1.1.0
fun getContainerItemSkip(): Int

Accessor for the skip value

Returns
Int

skip value

getDebugName

Added in 1.1.0
fun getDebugName(): String!

Returns the name of this widget (used for debug purposes)

Returns
String!

the debug name

getDimensionBehaviour

Added in 1.1.0
fun getDimensionBehaviour(orientation: Int): ConstraintWidget.DimensionBehaviour!

Get the widget's DimensionBehaviour in an specific orientation.

getDimensionRatio

Added in 1.1.0
fun getDimensionRatio(): Float

Return the current ratio of this widget

Returns
Float

the dimension ratio (HORIZONTAL, VERTICAL, or UNKNOWN)

getDimensionRatioSide

Added in 1.1.0
fun getDimensionRatioSide(): Int

Return the current side on which ratio will be applied

Returns
Int

HORIZONTAL, VERTICAL, or UNKNOWN

getHasBaseline

Added in 1.1.0
fun getHasBaseline(): Boolean

getHeight

Added in 1.1.0
fun getHeight(): Int

Return the height of the widget

Returns
Int

height height

getHorizontalBiasPercent

Added in 1.1.0
fun getHorizontalBiasPercent(): Float

Return the horizontal percentage bias that is used when two opposite connections exist of the same strength.

Returns
Float

horizontal percentage bias

getHorizontalChainControlWidget

Added in 1.1.0
fun getHorizontalChainControlWidget(): ConstraintWidget!

if in a horizontal chain return the left most widget in the chain.

Returns
ConstraintWidget!

left most widget in chain or null

getHorizontalChainStyle

Added in 1.1.0
fun getHorizontalChainStyle(): Int

get the chain starting from this widget to be packed. The horizontal bias will control how elements of the chain are positioned.

Returns
Int

Horizontal Chain Style

getHorizontalDimensionBehaviour

Added in 1.1.0
fun getHorizontalDimensionBehaviour(): ConstraintWidget.DimensionBehaviour!

Accessor for the horizontal dimension behaviour

Returns
ConstraintWidget.DimensionBehaviour!

dimension behaviour

getHorizontalMargin

Added in 1.1.0
fun getHorizontalMargin(): Int

Returns all the horizontal margin of the widget.

getLastHorizontalMeasureSpec

Added in 1.1.0
fun getLastHorizontalMeasureSpec(): Int

getLastVerticalMeasureSpec

Added in 1.1.0
fun getLastVerticalMeasureSpec(): Int

getLeft

Added in 1.1.0
fun getLeft(): Int

Return the left position of the widget (similar to getX)

Returns
Int

left position of the widget

getLength

Added in 1.1.0
fun getLength(orientation: Int): Int

Get a dimension of the widget in a particular orientation.

Returns
Int

The dimension of the specified orientation.

getMaxHeight

Added in 1.1.0
fun getMaxHeight(): Int

getMaxWidth

Added in 1.1.0
fun getMaxWidth(): Int

getMinHeight

Added in 1.1.0
fun getMinHeight(): Int

Return the minimum height of the widget

Returns
Int

minimum height

getMinWidth

Added in 1.1.0
fun getMinWidth(): Int

Return the minimum width of the widget

Returns
Int

minimum width

getNextChainMember

Added in 1.1.0
fun getNextChainMember(orientation: Int): ConstraintWidget!

Return the next chain member if one exists

Parameters
orientation: Int

HORIZONTAL or VERTICAL

Returns
ConstraintWidget!

the next chain member or null if we are the last chain element

getOptimizerWrapHeight

Added in 1.1.0
fun getOptimizerWrapHeight(): Int

getOptimizerWrapWidth

Added in 1.1.0
fun getOptimizerWrapWidth(): Int

getParent

Added in 1.1.0
fun getParent(): ConstraintWidget!

Returns the parent of this widget if there is one

Returns
ConstraintWidget!

parent

getPreviousChainMember

Added in 1.1.0
fun getPreviousChainMember(orientation: Int): ConstraintWidget!

Return the previous chain member if one exists

Parameters
orientation: Int

HORIZONTAL or VERTICAL

Returns
ConstraintWidget!

the previous chain member or null if we are the first chain element

getRight

Added in 1.1.0
fun getRight(): Int

Return the right position of the widget

Returns
Int

right position of the widget

getRun

Added in 1.1.0
fun getRun(orientation: Int): WidgetRun!

getSceneString

Added in 1.1.0
fun getSceneString(ret: StringBuilder!): Unit

getTop

Added in 1.1.0
fun getTop(): Int

Return the top position of the widget (similar to getY)

Returns
Int

top position of the widget

getType

Added in 1.1.0
fun getType(): String!

Returns the type string if set

Returns
String!

type (null if not set)

getVerticalBiasPercent

Added in 1.1.0
fun getVerticalBiasPercent(): Float

Return the vertical percentage bias that is used when two opposite connections exist of the same strength.

Returns
Float

vertical percentage bias

getVerticalChainControlWidget

Added in 1.1.0
fun getVerticalChainControlWidget(): ConstraintWidget!

if in a vertical chain return the top most widget in the chain.

Returns
ConstraintWidget!

top most widget in chain or null

getVerticalChainStyle

Added in 1.1.0
fun getVerticalChainStyle(): Int

Set the chain starting from this widget to be packed. The vertical bias will control how elements of the chain are positioned.

getVerticalDimensionBehaviour

Added in 1.1.0
fun getVerticalDimensionBehaviour(): ConstraintWidget.DimensionBehaviour!

Accessor for the vertical dimension behaviour

Returns
ConstraintWidget.DimensionBehaviour!

dimension behaviour

getVerticalMargin

Added in 1.1.0
fun getVerticalMargin(): Int

Returns all the vertical margin of the widget

getVisibility

Added in 1.1.0
fun getVisibility(): Int

Returns the current visibility value for this widget

Returns
Int

the visibility (VISIBLE, INVISIBLE, or GONE)

getWidth

Added in 1.1.0
fun getWidth(): Int

Return the width of the widget

Returns
Int

width width

getWrapBehaviorInParent

Added in 1.1.0
fun getWrapBehaviorInParent(): Int

getX

Added in 1.1.0
fun getX(): Int

Return the x position of the widget, relative to its container

Returns
Int

x position

getY

Added in 1.1.0
fun getY(): Int

Return the y position of the widget, relative to its container

Returns
Int

y position

hasBaseline

Added in 1.1.0
fun hasBaseline(): Boolean

Return true if this widget has a baseline

Returns
Boolean

true if the widget has a baseline, false otherwise

hasDanglingDimension

Added in 1.1.0
fun hasDanglingDimension(orientation: Int): Boolean

hasDependencies

Added in 1.1.0
fun hasDependencies(): Boolean

hasDimensionOverride

Added in 1.1.0
fun hasDimensionOverride(): Boolean

hasResolvedTargets

Added in 1.1.0
fun hasResolvedTargets(orientation: Int, size: Int): Boolean

immediateConnect

Added in 1.1.0
fun immediateConnect(
    startType: ConstraintAnchor.Type!,
    target: ConstraintWidget!,
    endType: ConstraintAnchor.Type!,
    margin: Int,
    goneMargin: Int
): Unit

Immediate connection to an anchor without any checks.

Parameters
startType: ConstraintAnchor.Type!

The type of anchor on this widget

target: ConstraintWidget!

The target widget

endType: ConstraintAnchor.Type!

The type of anchor on the target widget

margin: Int

How much margin we want to keep as a minimum distance between the two anchors

goneMargin: Int

How much margin we want to keep if the target is set to View.GONE

isAnimated

Added in 1.1.0
fun isAnimated(): Boolean

Returns if this widget is animated. Currently only affects gone behaviour

Returns
Boolean

true if ConstraintWidget is used in Animation

isHeightWrapContent

Added in 1.1.0
fun isHeightWrapContent(): Boolean

Returns true if height is set to wrap_content

isHorizontalSolvingPassDone

Added in 1.1.0
fun isHorizontalSolvingPassDone(): Boolean

isInBarrier

Added in 1.1.0
fun isInBarrier(orientation: Int): Boolean

isInHorizontalChain

Added in 1.1.0
fun isInHorizontalChain(): Boolean

Test if you are in a Horizontal chain

Returns
Boolean

true if in a horizontal chain

isInPlaceholder

Added in 1.1.0
fun isInPlaceholder(): Boolean

isInVerticalChain

Added in 1.1.0
fun isInVerticalChain(): Boolean

Test if you are in a vertical chain

Returns
Boolean

true if in a vertical chain

isInVirtualLayout

Added in 1.1.0
fun isInVirtualLayout(): Boolean

isMeasureRequested

Added in 1.1.0
fun isMeasureRequested(): Boolean

isResolvedHorizontally

Added in 1.1.0
fun isResolvedHorizontally(): Boolean

isResolvedVertically

Added in 1.1.0
fun isResolvedVertically(): Boolean

isRoot

Added in 1.1.0
fun isRoot(): Boolean

Returns true if the widget is the root widget

Returns
Boolean

true if root widget, false otherwise

isSpreadHeight

Added in 1.1.0
fun isSpreadHeight(): Boolean

isSpreadWidth

Added in 1.1.0
fun isSpreadWidth(): Boolean

isVerticalSolvingPassDone

Added in 1.1.0
fun isVerticalSolvingPassDone(): Boolean

isWidthWrapContent

Added in 1.1.0
fun isWidthWrapContent(): Boolean

Returns true if width is set to wrap_content

markHorizontalSolvingPassDone

Added in 1.1.0
fun markHorizontalSolvingPassDone(): Unit

markVerticalSolvingPassDone

Added in 1.1.0
fun markVerticalSolvingPassDone(): Unit

oppositeDimensionDependsOn

Added in 1.1.0
fun oppositeDimensionDependsOn(orientation: Int): Boolean

oppositeDimensionsTied

Added in 1.1.0
fun oppositeDimensionsTied(): Boolean

reset

Added in 1.1.0
fun reset(): Unit

resetAllConstraints

Added in 1.1.0
fun resetAllConstraints(): Unit

Reset all the constraints set on this widget

resetAnchor

Added in 1.1.0
fun resetAnchor(anchor: ConstraintAnchor!): Unit

Reset the given anchor

Parameters
anchor: ConstraintAnchor!

the anchor we want to reset

resetAnchors

Added in 1.1.0
fun resetAnchors(): Unit

Reset all connections

resetFinalResolution

Added in 1.1.0
fun resetFinalResolution(): Unit

resetSolverVariables

Added in 1.1.0
fun resetSolverVariables(cache: Cache!): Unit

Reset the solver variables of the anchors

resetSolvingPassFlag

Added in 1.1.0
fun resetSolvingPassFlag(): Unit

serialize

Added in 1.1.0
fun serialize(ret: StringBuilder!): StringBuilder!

Serialize the anchors for JSON5 output

Parameters
ret: StringBuilder!

StringBuilder to be populated

Returns
StringBuilder!

the same string builder to alow chaining

setAnimated

Added in 1.1.0
fun setAnimated(animated: Boolean): Unit

Set if this widget is animated. Currently only affects gone behaviour

Parameters
animated: Boolean

if true the widget must be positioned correctly when not visible

setBaselineDistance

Added in 1.1.0
fun setBaselineDistance(baseline: Int): Unit

Set the baseline distance relative to the top of the widget

Parameters
baseline: Int

the distance of the baseline relative to the widget's top

setCompanionWidget

Added in 1.1.0
fun setCompanionWidget(companion: Any!): Unit

Set the companion widget. Typically, this would be the real widget we represent with this instance of ConstraintWidget.

setContainerItemSkip

Added in 1.1.0
fun setContainerItemSkip(skip: Int): Unit

Set the skip value for this widget. This can be used when a widget is in a container, so that container can position the widget as if it was positioned further in the list of widgets. For example, with Table, this is used to skip empty cells (the widget after an empty cell will have a skip value of one)

setDebugName

Added in 1.1.0
fun setDebugName(name: String!): Unit

Set the debug name of this widget

setDebugSolverName

Added in 1.1.0
fun setDebugSolverName(system: LinearSystem!, name: String!): Unit

Utility debug function. Sets the names of the anchors in the solver given a widget's name. The given name is used as a prefix, resulting in anchors' names of the form:

  • {name}.left
  • {name}.top
  • {name}.right
  • {name}.bottom
  • {name}.baseline
Parameters
system: LinearSystem!

solver used

name: String!

name of the widget

setDimension

Added in 1.1.0
fun setDimension(w: Int, h: Int): Unit

Set both width and height of the widget

Parameters
w: Int

width

h: Int

height

setDimensionRatio

Added in 1.1.0
fun setDimensionRatio(ratio: String!): Unit

Set the ratio of the widget

Parameters
ratio: String!

given string of format [H|V],[float|x:y] or [float|x:y]

setDimensionRatio

Added in 1.1.0
fun setDimensionRatio(ratio: Float, dimensionRatioSide: Int): Unit

Set the ratio of the widget The ratio will be applied if at least one of the dimension (width or height) is set to a behaviour of DimensionBehaviour.MATCH_CONSTRAINT -- the dimension's value will be set to the other dimension * ratio.

Parameters
ratio: Float

A float value that describes W/H or H/W depending on the provided dimensionRatioSide

dimensionRatioSide: Int

The side the ratio should be calculated on, HORIZONTAL, VERTICAL, or UNKNOWN

setFinalBaseline

Added in 1.1.0
fun setFinalBaseline(baselineValue: Int): Unit

setFinalFrame

Added in 1.1.0
fun setFinalFrame(
    left: Int,
    top: Int,
    right: Int,
    bottom: Int,
    baseline: Int,
    orientation: Int
): Unit

setFinalHorizontal

Added in 1.1.0
fun setFinalHorizontal(x1: Int, x2: Int): Unit

setFinalLeft

Added in 1.1.0
fun setFinalLeft(x1: Int): Unit

setFinalTop

Added in 1.1.0
fun setFinalTop(y1: Int): Unit

setFinalVertical

Added in 1.1.0
fun setFinalVertical(y1: Int, y2: Int): Unit

setFrame

Added in 1.1.0
fun setFrame(start: Int, end: Int, orientation: Int): Unit

Set the position+dimension of the widget based on starting/ending positions on one dimension.

Parameters
start: Int

Left/Top side position of the widget.

end: Int

Right/Bottom side position of the widget.

orientation: Int

Orientation being set (HORIZONTAL/VERTICAL).

setFrame

Added in 1.1.0
fun setFrame(left: Int, top: Int, right: Int, bottom: Int): Unit

Set the position+dimension of the widget given left/top/right/bottom

Parameters
left: Int

left side position of the widget

top: Int

top side position of the widget

right: Int

right side position of the widget

bottom: Int

bottom side position of the widget

setGoneMargin

Added in 1.1.0
fun setGoneMargin(type: ConstraintAnchor.Type!, goneMargin: Int): Unit

Set the margin to be used when connected to a widget with a visibility of GONE

Parameters
type: ConstraintAnchor.Type!

the anchor to set the margin on

goneMargin: Int

the margin value to use

setHasBaseline

Added in 1.1.0
fun setHasBaseline(hasBaseline: Boolean): Unit

setHeight

Added in 1.1.0
fun setHeight(h: Int): Unit

Set the height of the widget

Parameters
h: Int

height

setHeightWrapContent

Added in 1.1.0
fun setHeightWrapContent(heightWrapContent: Boolean): Unit

Keep track of wrap_content for height

setHorizontalBiasPercent

Added in 1.1.0
fun setHorizontalBiasPercent(horizontalBiasPercent: Float): Unit

Set the horizontal bias percent to apply when we have two opposite constraints of equal strength

Parameters
horizontalBiasPercent: Float

the percentage used

setHorizontalChainStyle

Added in 1.1.0
fun setHorizontalChainStyle(horizontalChainStyle: Int): Unit

Set the chain starting from this widget to be packed. The horizontal bias will control how elements of the chain are positioned.

Parameters
horizontalChainStyle: Int

(CHAIN_SPREAD, CHAIN_SPREAD_INSIDE, CHAIN_PACKED)

setHorizontalDimension

Added in 1.1.0
fun setHorizontalDimension(left: Int, right: Int): Unit

Set the positions for the horizontal dimension only

Parameters
left: Int

left side position of the widget

right: Int

right side position of the widget

setHorizontalDimensionBehaviour

Added in 1.1.0
fun setHorizontalDimensionBehaviour(
    behaviour: ConstraintWidget.DimensionBehaviour!
): Unit

Set the widget's behaviour for the horizontal dimension

Parameters
behaviour: ConstraintWidget.DimensionBehaviour!

the horizontal dimension's behaviour

setHorizontalMatchStyle

Added in 1.1.0
fun setHorizontalMatchStyle(
    horizontalMatchStyle: Int,
    min: Int,
    max: Int,
    percent: Float
): Unit

Set the horizontal style when MATCH_CONSTRAINT is set

Parameters
horizontalMatchStyle: Int

MATCH_CONSTRAINT_SPREAD or MATCH_CONSTRAINT_WRAP

min: Int

minimum value

max: Int

maximum value

percent: Float

Percent width

setHorizontalWeight

Added in 1.1.0
fun setHorizontalWeight(horizontalWeight: Float): Unit

Set the horizontal weight (only used in chains)

Parameters
horizontalWeight: Float

Floating point value weight

setInPlaceholder

Added in 1.1.0
fun setInPlaceholder(inPlaceholder: Boolean): Unit

setInVirtualLayout

Added in 1.1.0
fun setInVirtualLayout(inVirtualLayout: Boolean): Unit

setLastMeasureSpec

Added in 1.1.0
fun setLastMeasureSpec(horizontal: Int, vertical: Int): Unit

setLength

Added in 1.1.0
fun setLength(length: Int, orientation: Int): Unit

Set the dimension of a widget in a particular orientation.

Parameters
length: Int

Size of the dimension.

orientation: Int

HORIZONTAL or VERTICAL

setMaxHeight

Added in 1.1.0
fun setMaxHeight(maxHeight: Int): Unit

setMaxWidth

Added in 1.1.0
fun setMaxWidth(maxWidth: Int): Unit

setMeasureRequested

Added in 1.1.0
fun setMeasureRequested(measureRequested: Boolean): Unit

setMinHeight

Added in 1.1.0
fun setMinHeight(h: Int): Unit

Set the minimum height of the widget

Parameters
h: Int

minimum height

setMinWidth

Added in 1.1.0
fun setMinWidth(w: Int): Unit

Set the minimum width of the widget

Parameters
w: Int

minimum width

setOffset

Added in 1.1.0
fun setOffset(x: Int, y: Int): Unit

Set the offset of this widget relative to the root widget

Parameters
x: Int

horizontal offset

y: Int

vertical offset

setOrigin

Added in 1.1.0
fun setOrigin(x: Int, y: Int): Unit

Set both the origin in (x, y) of the widget, relative to its container

Parameters
x: Int

x position

y: Int

y position

setParent

Added in 1.1.0
fun setParent(widget: ConstraintWidget!): Unit

Set the parent of this widget

Parameters
widget: ConstraintWidget!

parent

setType

Added in 1.1.0
fun setType(type: String!): Unit

Set the type of the widget (as a String)

Parameters
type: String!

type of the widget

setVerticalBiasPercent

Added in 1.1.0
fun setVerticalBiasPercent(verticalBiasPercent: Float): Unit

Set the vertical bias percent to apply when we have two opposite constraints of equal strength

Parameters
verticalBiasPercent: Float

the percentage used

setVerticalChainStyle

Added in 1.1.0
fun setVerticalChainStyle(verticalChainStyle: Int): Unit

Set the chain starting from this widget to be packed. The vertical bias will control how elements of the chain are positioned.

Parameters
verticalChainStyle: Int

(CHAIN_SPREAD, CHAIN_SPREAD_INSIDE, CHAIN_PACKED)

setVerticalDimension

Added in 1.1.0
fun setVerticalDimension(top: Int, bottom: Int): Unit

Set the positions for the vertical dimension only

Parameters
top: Int

top side position of the widget

bottom: Int

bottom side position of the widget

setVerticalDimensionBehaviour

Added in 1.1.0
fun setVerticalDimensionBehaviour(
    behaviour: ConstraintWidget.DimensionBehaviour!
): Unit

Set the widget's behaviour for the vertical dimension

Parameters
behaviour: ConstraintWidget.DimensionBehaviour!

the vertical dimension's behaviour

setVerticalMatchStyle

Added in 1.1.0
fun setVerticalMatchStyle(
    verticalMatchStyle: Int,
    min: Int,
    max: Int,
    percent: Float
): Unit

Set the vertical style when MATCH_CONSTRAINT is set

Parameters
verticalMatchStyle: Int

MATCH_CONSTRAINT_SPREAD or MATCH_CONSTRAINT_WRAP

min: Int

minimum value

max: Int

maximum value

percent: Float

Percent height

setVerticalWeight

Added in 1.1.0
fun setVerticalWeight(verticalWeight: Float): Unit

Set the vertical weight (only used in chains)

Parameters
verticalWeight: Float

Floating point value weight

setVisibility

Added in 1.1.0
fun setVisibility(visibility: Int): Unit

Set the visibility for this widget

Parameters
visibility: Int

either VISIBLE, INVISIBLE, or GONE

setWidth

Added in 1.1.0
fun setWidth(w: Int): Unit

Set the width of the widget

Parameters
w: Int

width

setWidthWrapContent

Added in 1.1.0
fun setWidthWrapContent(widthWrapContent: Boolean): Unit

Keep track of wrap_content for width

setWrapBehaviorInParent

Added in 1.1.0
fun setWrapBehaviorInParent(behavior: Int): Unit

setX

Added in 1.1.0
fun setX(x: Int): Unit

Set the x position of the widget, relative to its container

Parameters
x: Int

x position

setY

Added in 1.1.0
fun setY(y: Int): Unit

Set the y position of the widget, relative to its container

Parameters
y: Int

y position

setupDimensionRatio

Added in 1.1.0
fun setupDimensionRatio(
    hParentWrapContent: Boolean,
    vParentWrapContent: Boolean,
    horizontalDimensionFixed: Boolean,
    verticalDimensionFixed: Boolean
): Unit

Resolves the dimension ratio parameters (mResolvedDimensionRatioSide &mDimensionRatio)

Parameters
hParentWrapContent: Boolean

true if parent is in wrap content horizontally

vParentWrapContent: Boolean

true if parent is in wrap content vertically

horizontalDimensionFixed: Boolean

true if this widget horizontal dimension is fixed

verticalDimensionFixed: Boolean

true if this widget vertical dimension is fixed

toString

fun toString(): String!

Returns a string representation of the ConstraintWidget

Returns
String!

string representation of the widget

updateFromRuns

Added in 1.1.0
fun updateFromRuns(updateHorizontal: Boolean, updateVertical: Boolean): Unit

updateFromSolver

Added in 1.1.0
fun updateFromSolver(system: LinearSystem!, optimize: Boolean): Unit

Update the widget from the values generated by the solver

Parameters
system: LinearSystem!

the solver we get the values from.

optimize: Boolean

true if OPTIMIZATION_GRAPH is on

Protected functions

getRootX

Added in 1.1.0
protected fun getRootX(): Int

Return the x position of the widget, relative to the root (without animation)

Returns
Int

x position

getRootY

Added in 1.1.0
protected fun getRootY(): Int

Return the y position of the widget, relative to the root (without animation)

setInBarrier

Added in 1.1.0
protected fun setInBarrier(orientation: Int, value: Boolean): Unit

Public properties

DEFAULT_BIAS

Added in 1.1.0
java-static val DEFAULT_BIASFloat

frame

Added in 1.1.0
val frameWidgetFrame!

horizontalChainRun

Added in 1.1.0
val horizontalChainRunChainRun!

horizontalGroup

Added in 1.1.0
val horizontalGroupInt

isTerminalWidget

Added in 1.1.0
val isTerminalWidgetBooleanArray<Boolean>!

mBaseline

Added in 1.1.0
val mBaselineConstraintAnchor!

mBottom

Added in 1.1.0
val mBottomConstraintAnchor!

mCenter

Added in 1.1.0
val mCenterConstraintAnchor!

mCircleConstraintAngle

Added in 1.1.0
val mCircleConstraintAngleFloat

mDimensionRatio

Added in 1.1.0
val mDimensionRatioFloat

mHorizontalResolution

Added in 1.1.0
val mHorizontalResolutionInt

mHorizontalRun

Added in 1.1.0
val mHorizontalRunHorizontalWidgetRun!

mIsHeightWrapContent

Added in 1.1.0
val mIsHeightWrapContentBoolean

mIsWidthWrapContent

Added in 1.1.0
val mIsWidthWrapContentBoolean

mLeft

Added in 1.1.0
val mLeftConstraintAnchor!

mListAnchors

Added in 1.1.0
val mListAnchorsArray<ConstraintAnchor!>!

mListDimensionBehaviors

Added in 1.1.0
val mListDimensionBehaviorsArray<ConstraintWidget.DimensionBehaviour!>!

mMatchConstraintDefaultHeight

Added in 1.1.0
val mMatchConstraintDefaultHeightInt

mMatchConstraintDefaultWidth

Added in 1.1.0
val mMatchConstraintDefaultWidthInt

mMatchConstraintMaxHeight

Added in 1.1.0
val mMatchConstraintMaxHeightInt

mMatchConstraintMaxWidth

Added in 1.1.0
val mMatchConstraintMaxWidthInt

mMatchConstraintMinHeight

Added in 1.1.0
val mMatchConstraintMinHeightInt

mMatchConstraintMinWidth

Added in 1.1.0
val mMatchConstraintMinWidthInt

mMatchConstraintPercentHeight

Added in 1.1.0
val mMatchConstraintPercentHeightFloat

mMatchConstraintPercentWidth

Added in 1.1.0
val mMatchConstraintPercentWidthFloat

mParent

Added in 1.1.0
val mParentConstraintWidget!

mResolvedMatchConstraintDefault

Added in 1.1.0
val mResolvedMatchConstraintDefaultIntArray<Int>!

mRight

Added in 1.1.0
val mRightConstraintAnchor!

mTop

Added in 1.1.0
val mTopConstraintAnchor!

mVerticalResolution

Added in 1.1.0
val mVerticalResolutionInt

mVerticalRun

Added in 1.1.0
val mVerticalRunVerticalWidgetRun!

mWeight

Added in 1.1.0
val mWeightFloatArray<Float>!

measured

Added in 1.1.0
val measuredBoolean

run

Added in 1.1.0
val runArray<WidgetRun!>!

stringId

Added in 1.1.0
val stringIdString!

verticalChainRun

Added in 1.1.0
val verticalChainRunChainRun!

verticalGroup

Added in 1.1.0
val verticalGroupInt

Protected properties

mAnchors

Added in 1.1.0
protected val mAnchorsArrayList<ConstraintAnchor!>!

mDimensionRatioSide

Added in 1.1.0
protected val mDimensionRatioSideInt

mListNextMatchConstraintsWidget

Added in 1.1.0
protected val mListNextMatchConstraintsWidgetArray<ConstraintWidget!>!

mMinHeight

Added in 1.1.0
protected val mMinHeightInt

mMinWidth

Added in 1.1.0
protected val mMinWidthInt

mNextChainWidget

Added in 1.1.0
protected val mNextChainWidgetArray<ConstraintWidget!>!

mOffsetX

Added in 1.1.0
protected val mOffsetXInt

mOffsetY

Added in 1.1.0
protected val mOffsetYInt

mX

Added in 1.1.0
protected val mXInt

mY

Added in 1.1.0
protected val mYInt