ConstraintWidgetContainer


public class ConstraintWidgetContainer extends WidgetContainer


A container of ConstraintWidget that can layout its children

Summary

Public constructors

Default constructor

ConstraintWidgetContainer(int width, int height)

Constructor

ConstraintWidgetContainer(String debugName, int width, int height)
ConstraintWidgetContainer(int x, int y, int width, int height)

Constructor

Public methods

boolean

Add this widget to the solver

void
void
void
boolean
directMeasure(boolean optimizeWrap)
boolean
directMeasureSetup(boolean optimizeWrap)
boolean
directMeasureWithOrientation(boolean optimizeWrap, int orientation)
void
ArrayList<Guideline>

Accessor to the horizontal guidelines contained in the table.

BasicMeasure.Measurer
int

Returns the current optimization level

void
LinearSystem
String

Specify the xml type for the container

ArrayList<Guideline>

Accessor to the vertical guidelines contained in the table.

boolean

Indicates if the container knows how to layout its content on its own

void

Invalidate the graph of constraints

void

Invalidate the widgets measures

boolean

Return true if the height given is too small for the content laid out

boolean

Returns the rtl status.

boolean

Return true if the width given is too small for the content laid out

void

Layout the tree of widgets

static boolean
measure(
    int level,
    ConstraintWidget widget,
    BasicMeasure.Measurer measurer,
    BasicMeasure.Measure measure,
    int measureStrategy
)
long
measure(
    int optimizationLevel,
    int widthMode,
    int widthSize,
    int heightMode,
    int heightSize,
    int lastMeasureWidth,
    int lastMeasureHeight,
    int paddingX,
    int paddingY
)

Measure the layout

boolean
optimizeFor(int feature)

Returns true if the given feature should be optimized

void
void
void

Resolves the system directly when possible

void
setPadding(int left, int top, int right, int bottom)

Set the padding on this container.

void
setPass(int pass)

Keep track of the # of passes

void
setRtl(boolean isRtl)

Set the rtl status.

boolean
updateChildrenFromSolver(LinearSystem system, boolean[] flags)

Update the frame of the layout and its children from the solver

void
updateFromRuns(boolean updateHorizontal, boolean updateVertical)
void

Inherited Constants

From androidx.constraintlayout.core.widgets.ConstraintWidget
static final int
static final int
static final int
static final int
static final int
static final int
BOTH = 2
static final int
static final int
static final int
static final int
DIRECT = 2
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
SOLVER = 1
static final int
UNKNOWN = -1
static final int
static final int
static final int
static final int
static final int
static final int

Inherited methods

From androidx.constraintlayout.core.widgets.ConstraintWidget
void
addChildrenToSolverByDependency(
    ConstraintWidgetContainer container,
    LinearSystem system,
    HashSet<ConstraintWidget> widgets,
    int orientation,
    boolean addSelf
)
void
addToSolver(LinearSystem system, boolean optimize)

Add this widget to the solver

boolean

Returns true if this widget should be used in a barrier

void
connect(
    ConstraintAnchor.Type constraintFrom,
    ConstraintWidget target,
    ConstraintAnchor.Type constraintTo
)

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

void
connect(ConstraintAnchor from, ConstraintAnchor to, int margin)

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

void
connect(
    ConstraintAnchor.Type constraintFrom,
    ConstraintWidget target,
    ConstraintAnchor.Type constraintTo,
    int margin
)

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

void
connectCircularConstraint(
    ConstraintWidget target,
    float angle,
    int radius
)

Set a circular constraint

void
void

Create all the system variables for this widget

void
void
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(int orientation)

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

Object

Return the companion widget.

int

Accessor for the skip value

String

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

ConstraintWidget.DimensionBehaviour
getDimensionBehaviour(int orientation)

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(int orientation)

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(int orientation)

Return the next chain member if one exists

int
int
ConstraintWidget

Returns the parent of this widget if there is one

ConstraintWidget
getPreviousChainMember(int orientation)

Return the previous chain member if one exists

int

Return the right position of the widget

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)

WidgetRun
getRun(int orientation)
int

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

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(int orientation)
boolean
boolean
boolean
hasResolvedTargets(int orientation, int size)
void
immediateConnect(
    ConstraintAnchor.Type startType,
    ConstraintWidget target,
    ConstraintAnchor.Type endType,
    int margin,
    int goneMargin
)

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(int orientation)
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

void
void
boolean
oppositeDimensionDependsOn(int orientation)
boolean
void

Reset all the constraints set on this widget

void

Reset the given anchor

void

Reset all connections

void
void
StringBuilder

Serialize the anchors for JSON5 output

void
setAnimated(boolean animated)

Set if this widget is animated.

void
setBaselineDistance(int baseline)

Set the baseline distance relative to the top of the widget

void

Set the companion widget.

void

Set the skip value for this widget.

void

Set the debug name of this widget

void

Utility debug function.

void
setDimension(int w, int h)

Set both width and height of the widget

void

Set the ratio of the widget

void
setDimensionRatio(float ratio, int dimensionRatioSide)

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.

void
setFinalBaseline(int baselineValue)
void
setFinalFrame(
    int left,
    int top,
    int right,
    int bottom,
    int baseline,
    int orientation
)
void
setFinalHorizontal(int x1, int x2)
void
setFinalLeft(int x1)
void
setFinalTop(int y1)
void
setFinalVertical(int y1, int y2)
void
setFrame(int start, int end, int orientation)

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

void
setFrame(int left, int top, int right, int bottom)

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

void
setGoneMargin(ConstraintAnchor.Type type, int goneMargin)

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

void
setHasBaseline(boolean hasBaseline)
void
setHeight(int h)

Set the height of the widget

void
setHeightWrapContent(boolean heightWrapContent)

Keep track of wrap_content for height

void
setHorizontalBiasPercent(float horizontalBiasPercent)

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

void
setHorizontalChainStyle(int horizontalChainStyle)

Set the chain starting from this widget to be packed.

void
setHorizontalDimension(int left, int right)

Set the positions for the horizontal dimension only

void

Set the widget's behaviour for the horizontal dimension

void
setHorizontalMatchStyle(
    int horizontalMatchStyle,
    int min,
    int max,
    float percent
)

Set the horizontal style when MATCH_CONSTRAINT is set

void
setHorizontalWeight(float horizontalWeight)

Set the horizontal weight (only used in chains)

void
setInBarrier(int orientation, boolean value)
void
setInPlaceholder(boolean inPlaceholder)
void
setInVirtualLayout(boolean inVirtualLayout)
void
setLastMeasureSpec(int horizontal, int vertical)
void
setLength(int length, int orientation)

Set the dimension of a widget in a particular orientation.

void
setMaxHeight(int maxHeight)
void
setMaxWidth(int maxWidth)
void
setMeasureRequested(boolean measureRequested)
void
setMinHeight(int h)

Set the minimum height of the widget

void
setMinWidth(int w)

Set the minimum width of the widget

void
setOrigin(int x, int y)

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

void

Set the parent of this widget

void

Set the type of the widget (as a String)

void
setVerticalBiasPercent(float verticalBiasPercent)

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

void
setVerticalChainStyle(int verticalChainStyle)

Set the chain starting from this widget to be packed.

void
setVerticalDimension(int top, int bottom)

Set the positions for the vertical dimension only

void

Set the widget's behaviour for the vertical dimension

void
setVerticalMatchStyle(
    int verticalMatchStyle,
    int min,
    int max,
    float percent
)

Set the vertical style when MATCH_CONSTRAINT is set

void
setVerticalWeight(float verticalWeight)

Set the vertical weight (only used in chains)

void
setVisibility(int visibility)

Set the visibility for this widget

void
setWidth(int w)

Set the width of the widget

void
setWidthWrapContent(boolean widthWrapContent)

Keep track of wrap_content for width

void
void
setX(int x)

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

void
setY(int y)

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

void
setupDimensionRatio(
    boolean hParentWrapContent,
    boolean vParentWrapContent,
    boolean horizontalDimensionFixed,
    boolean verticalDimensionFixed
)

Resolves the dimension ratio parameters (mResolvedDimensionRatioSide &mDimensionRatio)

String

Returns a string representation of the ConstraintWidget

void
updateFromSolver(LinearSystem system, boolean optimize)

Update the widget from the values generated by the solver

From androidx.constraintlayout.core.widgets.WidgetContainer
void

Add a child widget

void
add(ConstraintWidget[] widgets)

Add multiple child widgets.

ArrayList<ConstraintWidget>

Access the children

ConstraintWidgetContainer

Return the top-level ConstraintWidgetContainer

void

Remove a child widget

void
void

Reset the solver variables of the anchors

void
setOffset(int x, int y)

Set the offset of this widget relative to the root widget.

Public fields

mDependencyGraph

Added in 1.1.0
public DependencyGraph mDependencyGraph

mGroupsWrapOptimized

Added in 1.1.0
public boolean mGroupsWrapOptimized

mHorizontalChainsSize

Added in 1.1.0
public int mHorizontalChainsSize

mHorizontalWrapOptimized

Added in 1.1.0
public boolean mHorizontalWrapOptimized

mMeasure

Added in 1.1.0
public BasicMeasure.Measure mMeasure

mMetrics

Added in 1.1.0
public Metrics mMetrics

mSkipSolver

Added in 1.1.0
public boolean mSkipSolver

mVerticalChainsSize

Added in 1.1.0
public int mVerticalChainsSize

mVerticalWrapOptimized

Added in 1.1.0
public boolean mVerticalWrapOptimized

mWrapFixedHeight

Added in 1.1.0
public int mWrapFixedHeight

mWrapFixedWidth

Added in 1.1.0
public int mWrapFixedWidth

Protected fields

mMeasurer

Added in 1.1.0
protected BasicMeasure.Measurer mMeasurer

mSystem

Added in 1.1.0
protected LinearSystem mSystem

Public constructors

ConstraintWidgetContainer

Added in 1.1.0
public ConstraintWidgetContainer()

Default constructor

ConstraintWidgetContainer

Added in 1.1.0
public ConstraintWidgetContainer(int width, int height)

Constructor

Parameters
int width

width of the layout

int height

height of the layout

ConstraintWidgetContainer

Added in 1.1.0
public ConstraintWidgetContainer(String debugName, int width, int height)

ConstraintWidgetContainer

Added in 1.1.0
public ConstraintWidgetContainer(int x, int y, int width, int height)

Constructor

Parameters
int x

x position

int y

y position

int width

width of the layout

int height

height of the layout

Public methods

addChildrenToSolver

Added in 1.1.0
public boolean addChildrenToSolver(LinearSystem system)

Add this widget to the solver

Parameters
LinearSystem system

the solver we want to add the widget to

addHorizontalWrapMaxVariable

Added in 1.1.0
public void addHorizontalWrapMaxVariable(ConstraintAnchor right)

addHorizontalWrapMinVariable

Added in 1.1.0
public void addHorizontalWrapMinVariable(ConstraintAnchor left)

defineTerminalWidgets

Added in 1.1.0
public void defineTerminalWidgets()

directMeasure

Added in 1.1.0
public boolean directMeasure(boolean optimizeWrap)

directMeasureSetup

Added in 1.1.0
public boolean directMeasureSetup(boolean optimizeWrap)

directMeasureWithOrientation

Added in 1.1.0
public boolean directMeasureWithOrientation(boolean optimizeWrap, int orientation)

fillMetrics

Added in 1.1.0
public void fillMetrics(Metrics metrics)

getHorizontalGuidelines

Added in 1.1.0
public ArrayList<GuidelinegetHorizontalGuidelines()

Accessor to the horizontal guidelines contained in the table.

Returns
ArrayList<Guideline>

array of guidelines

getMeasurer

Added in 1.1.0
public BasicMeasure.Measurer getMeasurer()

getOptimizationLevel

Added in 1.1.0
public int getOptimizationLevel()

Returns the current optimization level

getSceneString

public void getSceneString(StringBuilder ret)

getSystem

Added in 1.1.0
public LinearSystem getSystem()

getType

public String getType()

Specify the xml type for the container

getVerticalGuidelines

Added in 1.1.0
public ArrayList<GuidelinegetVerticalGuidelines()

Accessor to the vertical guidelines contained in the table.

Returns
ArrayList<Guideline>

array of guidelines

handlesInternalConstraints

Added in 1.1.0
public boolean handlesInternalConstraints()

Indicates if the container knows how to layout its content on its own

Returns
boolean

true if the container does the layout, false otherwise

invalidateGraph

Added in 1.1.0
public void invalidateGraph()

Invalidate the graph of constraints

invalidateMeasures

Added in 1.1.0
public void invalidateMeasures()

Invalidate the widgets measures

isHeightMeasuredTooSmall

Added in 1.1.0
public boolean isHeightMeasuredTooSmall()

Return true if the height given is too small for the content laid out

isRtl

Added in 1.1.0
public boolean isRtl()

Returns the rtl status.

Returns
boolean

true if in RTL, false otherwise.

isWidthMeasuredTooSmall

Added in 1.1.0
public boolean isWidthMeasuredTooSmall()

Return true if the width given is too small for the content laid out

layout

public void layout()

Layout the tree of widgets

measure

Added in 1.1.0
public static boolean measure(
    int level,
    ConstraintWidget widget,
    BasicMeasure.Measurer measurer,
    BasicMeasure.Measure measure,
    int measureStrategy
)

measure

Added in 1.1.0
public long measure(
    int optimizationLevel,
    int widthMode,
    int widthSize,
    int heightMode,
    int heightSize,
    int lastMeasureWidth,
    int lastMeasureHeight,
    int paddingX,
    int paddingY
)

Measure the layout

optimizeFor

Added in 1.1.0
public boolean optimizeFor(int feature)

Returns true if the given feature should be optimized

reset

public void reset()

setMeasurer

Added in 1.1.0
public void setMeasurer(BasicMeasure.Measurer measurer)

setOptimizationLevel

Added in 1.1.0
public void setOptimizationLevel(int value)

Resolves the system directly when possible

Parameters
int value

optimization level

setPadding

Added in 1.1.0
public void setPadding(int left, int top, int right, int bottom)

Set the padding on this container. It will apply to the position of the children.

Parameters
int left

left padding

int top

top padding

int right

right padding

int bottom

bottom padding

setPass

Added in 1.1.0
public void setPass(int pass)

Keep track of the # of passes

setRtl

Added in 1.1.0
public void setRtl(boolean isRtl)

Set the rtl status. This has implications for Chains.

Parameters
boolean isRtl

true if we are in RTL.

updateChildrenFromSolver

Added in 1.1.0
public boolean updateChildrenFromSolver(LinearSystem system, boolean[] flags)

Update the frame of the layout and its children from the solver

Parameters
LinearSystem system

the solver we get the values from.

updateFromRuns

public void updateFromRuns(boolean updateHorizontal, boolean updateVertical)

updateHierarchy

Added in 1.1.0
public void updateHierarchy()