public class VirtualLayout extends HelperWidget

Known direct subclasses
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.


Base class for Virtual layouts

Summary

Protected fields

BasicMeasure.Measure

Public constructors

Public methods

void
applyRtl(boolean isRtl)
void
boolean
int
int
int
int
int
int
void
measure(int widthMode, int widthSize, int heightMode, int heightSize)
boolean
void
setMeasure(int width, int height)
void
setPadding(int value)
void
setPaddingBottom(int value)
void
setPaddingEnd(int value)
void
setPaddingLeft(int value)
void
setPaddingRight(int value)
void
setPaddingStart(int value)
void
setPaddingTop(int value)
void

Protected methods

void
measure(
    ConstraintWidget widget,
    ConstraintWidget.DimensionBehaviour horizontalBehavior,
    int horizontalDimension,
    ConstraintWidget.DimensionBehaviour verticalBehavior,
    int verticalDimension
)
boolean
void
needsCallbackFromSolver(boolean value)

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

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

Reset all the constraints set on this widget

void

Reset the given anchor

void

Reset all connections

void
void

Reset the solver variables of the anchors

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
setOffset(int x, int y)

Set the offset of this widget relative to the root 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
updateFromRuns(boolean updateHorizontal, boolean updateVertical)
void
updateFromSolver(LinearSystem system, boolean optimize)

Update the widget from the values generated by the solver

From androidx.constraintlayout.core.widgets.HelperWidget
void

Add a widget to the helper

void
addDependents(
    ArrayList<WidgetGroup> dependencyLists,
    int orientation,
    WidgetGroup group
)
void
int
findGroupInDependents(int orientation)
void

Reset the widgets list contained by this helper

Protected fields

mMeasure

Added in 1.1.0-alpha13
protected BasicMeasure.Measure mMeasure

Public constructors

VirtualLayout

Added in 1.1.0-alpha13
public VirtualLayout()

Public methods

applyRtl

Added in 1.1.0-alpha13
public void applyRtl(boolean isRtl)

captureWidgets

Added in 1.1.0-alpha13
public void captureWidgets()

contains

Added in 1.1.0-alpha13
public boolean contains(HashSet<ConstraintWidget> widgets)

getMeasuredHeight

Added in 1.1.0-alpha13
public int getMeasuredHeight()

getMeasuredWidth

Added in 1.1.0-alpha13
public int getMeasuredWidth()

getPaddingBottom

Added in 1.1.0-alpha13
public int getPaddingBottom()

getPaddingLeft

Added in 1.1.0-alpha13
public int getPaddingLeft()

getPaddingRight

Added in 1.1.0-alpha13
public int getPaddingRight()

getPaddingTop

Added in 1.1.0-alpha13
public int getPaddingTop()

measure

Added in 1.1.0-alpha13
public void measure(int widthMode, int widthSize, int heightMode, int heightSize)

needSolverPass

Added in 1.1.0-alpha13
public boolean needSolverPass()

setMeasure

Added in 1.1.0-alpha13
public void setMeasure(int width, int height)

setPadding

Added in 1.1.0-alpha13
public void setPadding(int value)

setPaddingBottom

Added in 1.1.0-alpha13
public void setPaddingBottom(int value)

setPaddingEnd

Added in 1.1.0-alpha13
public void setPaddingEnd(int value)

setPaddingLeft

Added in 1.1.0-alpha13
public void setPaddingLeft(int value)

setPaddingRight

Added in 1.1.0-alpha13
public void setPaddingRight(int value)

setPaddingStart

Added in 1.1.0-alpha13
public void setPaddingStart(int value)

setPaddingTop

Added in 1.1.0-alpha13
public void setPaddingTop(int value)

updateConstraints

public void updateConstraints(ConstraintWidgetContainer container)

Protected methods

measure

Added in 1.1.0-alpha13
protected void measure(
    ConstraintWidget widget,
    ConstraintWidget.DimensionBehaviour horizontalBehavior,
    int horizontalDimension,
    ConstraintWidget.DimensionBehaviour verticalBehavior,
    int verticalDimension
)

measureChildren

Added in 1.1.0-alpha13
protected boolean measureChildren()

needsCallbackFromSolver

Added in 1.1.0-alpha13
protected void needsCallbackFromSolver(boolean value)