public class ConstraintWidget
extends java.lang.Object
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 theconnect(androidx.constraintlayout.core.widgets.ConstraintAnchor, androidx.constraintlayout.core.widgets.ConstraintAnchor, int) function.| Modifier and Type | Class and Description |
|---|---|
static class |
ConstraintWidget.DimensionBehaviour
Define how the widget will resize
|
| Constructor and Description |
|---|
ConstraintWidget()
Default constructor
|
ConstraintWidget(int width,
int height)
Constructor
|
ConstraintWidget(int x,
int y,
int width,
int height)
Constructor
|
ConstraintWidget(java.lang.String debugName) |
ConstraintWidget(java.lang.String debugName,
int width,
int height) |
ConstraintWidget(java.lang.String debugName,
int x,
int y,
int width,
int height) |
| Modifier and Type | Method and Description |
|---|---|
void |
addChildrenToSolverByDependency(ConstraintWidgetContainer container,
LinearSystem system,
java.util.HashSet<ConstraintWidget> widgets,
int orientation,
boolean addSelf) |
void |
addToSolver(LinearSystem system,
boolean optimize)
Add this widget to the solver
|
boolean |
allowedInBarrier()
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.Type constraintFrom,
ConstraintWidget target,
ConstraintAnchor.Type constraintTo,
int margin)
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 |
connectCircularConstraint(ConstraintWidget target,
float angle,
int radius)
Set a circular constraint
|
void |
copy(ConstraintWidget src,
java.util.HashMap<ConstraintWidget,ConstraintWidget> map) |
void |
createObjectVariables(LinearSystem system)
Create all the system variables for this widget
|
void |
ensureMeasureRequested() |
void |
ensureWidgetRuns() |
ConstraintAnchor |
getAnchor(ConstraintAnchor.Type anchorType)
Given a type of anchor, returns the corresponding anchor.
|
java.util.ArrayList<ConstraintAnchor> |
getAnchors()
Return the array of anchors of this widget
|
int |
getBaselineDistance()
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 |
getBottom()
Return the bottom position of the widget
|
java.lang.Object |
getCompanionWidget()
Return the companion widget.
|
int |
getContainerItemSkip()
Accessor for the skip value
|
java.lang.String |
getDebugName()
Returns the name of this widget (used for debug purposes)
|
ConstraintWidget.DimensionBehaviour |
getDimensionBehaviour(int orientation)
Get the widget's
ConstraintWidget.DimensionBehaviour in an specific orientation. |
float |
getDimensionRatio()
Return the current ratio of this widget
|
int |
getDimensionRatioSide()
Return the current side on which ratio will be applied
|
boolean |
getHasBaseline() |
int |
getHeight()
Return the height of the widget
|
float |
getHorizontalBiasPercent()
Return the horizontal percentage bias that is used when two opposite connections
exist of the same strength.
|
ConstraintWidget |
getHorizontalChainControlWidget()
if in a horizontal chain return the left most widget in the chain.
|
int |
getHorizontalChainStyle()
get the chain starting from this widget to be packed.
|
ConstraintWidget.DimensionBehaviour |
getHorizontalDimensionBehaviour()
Accessor for the horizontal dimension behaviour
|
int |
getHorizontalMargin()
Returns all the horizontal margin of the widget.
|
int |
getLastHorizontalMeasureSpec() |
int |
getLastVerticalMeasureSpec() |
int |
getLeft()
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 |
getMaxHeight() |
int |
getMaxWidth() |
int |
getMinHeight()
Return the minimum height of the widget
|
int |
getMinWidth()
Return the minimum width of the widget
|
ConstraintWidget |
getNextChainMember(int orientation)
Return the next chain member if one exists
|
int |
getOptimizerWrapHeight() |
int |
getOptimizerWrapWidth() |
ConstraintWidget |
getParent()
Returns the parent of this widget if there is one
|
ConstraintWidget |
getPreviousChainMember(int orientation)
Return the previous chain member if one exists
|
int |
getRight()
Return the right position of the widget
|
protected int |
getRootX()
Return the x position of the widget, relative to the root
(without animation)
|
protected int |
getRootY()
Return the y position of the widget, relative to the root
(without animation)
|
WidgetRun |
getRun(int orientation) |
void |
getSceneString(java.lang.StringBuilder ret) |
int |
getTop()
Return the top position of the widget (similar to
getY()) |
java.lang.String |
getType()
Returns the type string if set
|
float |
getVerticalBiasPercent()
Return the vertical percentage bias that is used when two opposite connections
exist of the same strength.
|
ConstraintWidget |
getVerticalChainControlWidget()
if in a vertical chain return the top most widget in the chain.
|
int |
getVerticalChainStyle()
Set the chain starting from this widget to be packed.
|
ConstraintWidget.DimensionBehaviour |
getVerticalDimensionBehaviour()
Accessor for the vertical dimension behaviour
|
int |
getVerticalMargin()
Returns all the vertical margin of the widget
|
int |
getVisibility()
Returns the current visibility value for this widget
|
int |
getWidth()
Return the width of the widget
|
int |
getWrapBehaviorInParent() |
int |
getX()
Return the x position of the widget, relative to its container
|
int |
getY()
Return the y position of the widget, relative to its container
|
boolean |
hasBaseline()
Return true if this widget has a baseline
|
boolean |
hasDanglingDimension(int orientation) |
boolean |
hasDependencies() |
boolean |
hasDimensionOverride() |
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 |
isAnimated()
Returns if this widget is animated.
|
boolean |
isHeightWrapContent()
Returns true if height is set to wrap_content
|
boolean |
isHorizontalSolvingPassDone() |
boolean |
isInBarrier(int orientation) |
boolean |
isInHorizontalChain()
Test if you are in a Horizontal chain
|
boolean |
isInPlaceholder() |
boolean |
isInVerticalChain()
Test if you are in a vertical chain
|
boolean |
isInVirtualLayout() |
boolean |
isMeasureRequested() |
boolean |
isResolvedHorizontally() |
boolean |
isResolvedVertically() |
boolean |
isRoot()
Returns true if the widget is the root widget
|
boolean |
isSpreadHeight() |
boolean |
isSpreadWidth() |
boolean |
isVerticalSolvingPassDone() |
boolean |
isWidthWrapContent()
Returns true if width is set to wrap_content
|
void |
markHorizontalSolvingPassDone() |
void |
markVerticalSolvingPassDone() |
boolean |
oppositeDimensionDependsOn(int orientation) |
boolean |
oppositeDimensionsTied() |
void |
reset() |
void |
resetAllConstraints()
Reset all the constraints set on this widget
|
void |
resetAnchor(ConstraintAnchor anchor)
Reset the given anchor
|
void |
resetAnchors()
Reset all connections
|
void |
resetFinalResolution() |
void |
resetSolverVariables(Cache cache)
Reset the solver variables of the anchors
|
void |
resetSolvingPassFlag() |
java.lang.StringBuilder |
serialize(java.lang.StringBuilder ret) |
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 |
setCompanionWidget(java.lang.Object companion)
Set the companion widget.
|
void |
setContainerItemSkip(int skip)
Set the skip value for this widget.
|
void |
setDebugName(java.lang.String name)
Set the debug name of this widget
|
void |
setDebugSolverName(LinearSystem system,
java.lang.String name)
Utility debug function.
|
void |
setDimension(int w,
int h)
Set both width and height 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 |
setDimensionRatio(java.lang.String ratio)
Set the ratio of the widget
|
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 |
setHorizontalDimensionBehaviour(ConstraintWidget.DimensionBehaviour behaviour)
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)
|
protected 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 |
setParent(ConstraintWidget widget)
Set the parent of this widget
|
void |
setType(java.lang.String type)
Set the type of the widget (as a String)
|
void |
setupDimensionRatio(boolean hParentWrapContent,
boolean vParentWrapContent,
boolean horizontalDimensionFixed,
boolean verticalDimensionFixed)
Resolves the dimension ratio parameters
(mResolvedDimensionRatioSide & mDimensionRatio)
|
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 |
setVerticalDimensionBehaviour(ConstraintWidget.DimensionBehaviour behaviour)
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 |
setWrapBehaviorInParent(int behavior) |
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
|
java.lang.String |
toString()
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
|
protected static final int SOLVER
protected static final int DIRECT
public boolean measured
public WidgetRun[] run
public ChainRun horizontalChainRun
public ChainRun verticalChainRun
public HorizontalWidgetRun horizontalRun
public VerticalWidgetRun verticalRun
public boolean[] isTerminalWidget
public WidgetFrame frame
public java.lang.String stringId
public static final int MATCH_CONSTRAINT_SPREAD
public static final int MATCH_CONSTRAINT_WRAP
public static final int MATCH_CONSTRAINT_PERCENT
public static final int MATCH_CONSTRAINT_RATIO
public static final int MATCH_CONSTRAINT_RATIO_RESOLVED
public static final int UNKNOWN
public static final int HORIZONTAL
public static final int VERTICAL
public static final int BOTH
public static final int VISIBLE
public static final int INVISIBLE
public static final int GONE
public static final int CHAIN_SPREAD
public static final int CHAIN_SPREAD_INSIDE
public static final int CHAIN_PACKED
public static final int WRAP_BEHAVIOR_INCLUDED
public static final int WRAP_BEHAVIOR_HORIZONTAL_ONLY
public static final int WRAP_BEHAVIOR_VERTICAL_ONLY
public static final int WRAP_BEHAVIOR_SKIPPED
public int mHorizontalResolution
public int mVerticalResolution
public int mMatchConstraintDefaultWidth
public int mMatchConstraintDefaultHeight
public int[] mResolvedMatchConstraintDefault
public int mMatchConstraintMinWidth
public int mMatchConstraintMaxWidth
public float mMatchConstraintPercentWidth
public int mMatchConstraintMinHeight
public int mMatchConstraintMaxHeight
public float mMatchConstraintPercentHeight
public boolean mIsWidthWrapContent
public boolean mIsHeightWrapContent
public ConstraintAnchor mLeft
public ConstraintAnchor mTop
public ConstraintAnchor mRight
public ConstraintAnchor mBottom
public ConstraintAnchor mBaseline
public ConstraintAnchor mCenter
public static final int ANCHOR_LEFT
public static final int ANCHOR_RIGHT
public static final int ANCHOR_TOP
public static final int ANCHOR_BOTTOM
public static final int ANCHOR_BASELINE
public ConstraintAnchor[] mListAnchors
protected java.util.ArrayList<ConstraintAnchor> mAnchors
public ConstraintWidget.DimensionBehaviour[] mListDimensionBehaviors
public ConstraintWidget mParent
public float mDimensionRatio
protected int mDimensionRatioSide
protected int mX
protected int mY
protected int mOffsetX
protected int mOffsetY
protected int mMinWidth
protected int mMinHeight
public static float DEFAULT_BIAS
public float[] mWeight
protected ConstraintWidget[] mListNextMatchConstraintsWidget
protected ConstraintWidget[] mNextChainWidget
public int horizontalGroup
public int verticalGroup
public ConstraintWidget()
public ConstraintWidget(java.lang.String debugName)
public ConstraintWidget(int x,
int y,
int width,
int height)
x - x positiony - y positionwidth - width of the layoutheight - height of the layoutpublic ConstraintWidget(java.lang.String debugName,
int x,
int y,
int width,
int height)
public ConstraintWidget(int width,
int height)
width - width of the layoutheight - height of the layoutpublic ConstraintWidget(java.lang.String debugName,
int width,
int height)
public WidgetRun getRun(int orientation)
public void setFinalFrame(int left,
int top,
int right,
int bottom,
int baseline,
int orientation)
public void setFinalLeft(int x1)
public void setFinalTop(int y1)
public void resetSolvingPassFlag()
public boolean isHorizontalSolvingPassDone()
public boolean isVerticalSolvingPassDone()
public void markHorizontalSolvingPassDone()
public void markVerticalSolvingPassDone()
public void setFinalHorizontal(int x1,
int x2)
public void setFinalVertical(int y1,
int y2)
public void setFinalBaseline(int baselineValue)
public boolean isResolvedHorizontally()
public boolean isResolvedVertically()
public void resetFinalResolution()
public void ensureMeasureRequested()
public boolean hasDependencies()
public boolean hasDanglingDimension(int orientation)
public boolean hasResolvedTargets(int orientation,
int size)
public boolean isInVirtualLayout()
public void setInVirtualLayout(boolean inVirtualLayout)
public int getMaxHeight()
public int getMaxWidth()
public void setMaxWidth(int maxWidth)
public void setMaxHeight(int maxHeight)
public boolean isSpreadWidth()
public boolean isSpreadHeight()
public void setHasBaseline(boolean hasBaseline)
public boolean getHasBaseline()
public boolean isInPlaceholder()
public void setInPlaceholder(boolean inPlaceholder)
protected void setInBarrier(int orientation,
boolean value)
public boolean isInBarrier(int orientation)
public void setMeasureRequested(boolean measureRequested)
public boolean isMeasureRequested()
public void setWrapBehaviorInParent(int behavior)
public int getWrapBehaviorInParent()
public int getLastHorizontalMeasureSpec()
public int getLastVerticalMeasureSpec()
public void setLastMeasureSpec(int horizontal,
int vertical)
public void reset()
public java.lang.StringBuilder serialize(java.lang.StringBuilder ret)
public boolean oppositeDimensionDependsOn(int orientation)
public boolean oppositeDimensionsTied()
public boolean hasDimensionOverride()
public void ensureWidgetRuns()
public void resetSolverVariables(Cache cache)
public boolean isRoot()
public ConstraintWidget getParent()
public void setParent(ConstraintWidget widget)
widget - parentpublic void setWidthWrapContent(boolean widthWrapContent)
widthWrapContent - public boolean isWidthWrapContent()
public void setHeightWrapContent(boolean heightWrapContent)
heightWrapContent - public boolean isHeightWrapContent()
public void connectCircularConstraint(ConstraintWidget target, float angle, int radius)
target - the target widget we will use as the center of the circleangle - the angle (from 0 to 360)radius - the radius usedpublic java.lang.String getType()
public void setType(java.lang.String type)
type - type of the widgetpublic void setVisibility(int visibility)
visibility - either VISIBLE, INVISIBLE, or GONEpublic int getVisibility()
public void setAnimated(boolean animated)
animated - if true the widget must be positioned correctly when not visiblepublic boolean isAnimated()
public java.lang.String getDebugName()
public void setDebugName(java.lang.String name)
public void setDebugSolverName(LinearSystem system, java.lang.String name)
system - solver usedname - name of the widgetpublic void createObjectVariables(LinearSystem system)
system - public java.lang.String toString()
toString in class java.lang.Objectpublic int getX()
public int getY()
public int getWidth()
public int getOptimizerWrapWidth()
public int getOptimizerWrapHeight()
public int getHeight()
public int getLength(int orientation)
orientation - protected int getRootX()
protected int getRootY()
public int getMinWidth()
public int getMinHeight()
public int getLeft()
getX())public int getTop()
getY())public int getRight()
public int getBottom()
public int getHorizontalMargin()
public int getVerticalMargin()
public float getHorizontalBiasPercent()
public float getVerticalBiasPercent()
public float getBiasPercent(int orientation)
orientation - Orientation HORIZONTAL/VERTICAL.public boolean hasBaseline()
public int getBaselineDistance()
public java.lang.Object getCompanionWidget()
public java.util.ArrayList<ConstraintAnchor> getAnchors()
public void setX(int x)
x - x positionpublic void setY(int y)
y - y positionpublic void setOrigin(int x,
int y)
x - x positiony - y positionpublic void setOffset(int x,
int y)
x - horizontal offsety - vertical offsetpublic void setGoneMargin(ConstraintAnchor.Type type, int goneMargin)
type - the anchor to set the margin ongoneMargin - the margin value to usepublic void setWidth(int w)
w - widthpublic void setHeight(int h)
h - heightpublic void setLength(int length,
int orientation)
length - Size of the dimension.orientation - HORIZONTAL or VERTICALpublic void setHorizontalMatchStyle(int horizontalMatchStyle,
int min,
int max,
float percent)
horizontalMatchStyle - MATCH_CONSTRAINT_SPREAD or MATCH_CONSTRAINT_WRAPmin - minimum valuemax - maximum valuepercent - Percent widthpublic void setVerticalMatchStyle(int verticalMatchStyle,
int min,
int max,
float percent)
verticalMatchStyle - MATCH_CONSTRAINT_SPREAD or MATCH_CONSTRAINT_WRAPmin - minimum valuemax - maximum valuepercent - Percent heightpublic void setDimensionRatio(java.lang.String ratio)
ratio - given string of format [H|V],[float|x:y] or [float|x:y]public void setDimensionRatio(float ratio,
int dimensionRatioSide)
ratio - A float value that describes W/H or H/W depending on the provided dimensionRatioSidedimensionRatioSide - The side the ratio should be calculated on, HORIZONTAL, VERTICAL, or UNKNOWNpublic float getDimensionRatio()
public int getDimensionRatioSide()
public void setHorizontalBiasPercent(float horizontalBiasPercent)
horizontalBiasPercent - the percentage usedpublic void setVerticalBiasPercent(float verticalBiasPercent)
verticalBiasPercent - the percentage usedpublic void setMinWidth(int w)
w - minimum widthpublic void setMinHeight(int h)
h - minimum heightpublic void setDimension(int w,
int h)
w - widthh - heightpublic void setFrame(int left,
int top,
int right,
int bottom)
left - left side position of the widgettop - top side position of the widgetright - right side position of the widgetbottom - bottom side position of the widgetpublic void setFrame(int start,
int end,
int orientation)
start - Left/Top side position of the widget.end - Right/Bottom side position of the widget.orientation - Orientation being set (HORIZONTAL/VERTICAL).public void setHorizontalDimension(int left,
int right)
left - left side position of the widgetright - right side position of the widgetpublic void setVerticalDimension(int top,
int bottom)
top - top side position of the widgetbottom - bottom side position of the widgetpublic void setBaselineDistance(int baseline)
baseline - the distance of the baseline relative to the widget's toppublic void setCompanionWidget(java.lang.Object companion)
companion - public void setContainerItemSkip(int skip)
skip - public int getContainerItemSkip()
public void setHorizontalWeight(float horizontalWeight)
horizontalWeight - Floating point value weightpublic void setVerticalWeight(float verticalWeight)
verticalWeight - Floating point value weightpublic void setHorizontalChainStyle(int horizontalChainStyle)
horizontalChainStyle - (CHAIN_SPREAD, CHAIN_SPREAD_INSIDE, CHAIN_PACKED)public int getHorizontalChainStyle()
public void setVerticalChainStyle(int verticalChainStyle)
verticalChainStyle - (CHAIN_SPREAD, CHAIN_SPREAD_INSIDE, CHAIN_PACKED)public int getVerticalChainStyle()
public boolean allowedInBarrier()
public void immediateConnect(ConstraintAnchor.Type startType, ConstraintWidget target, ConstraintAnchor.Type endType, int margin, int goneMargin)
startType - The type of anchor on this widgettarget - The target widgetendType - The type of anchor on the target widgetmargin - How much margin we want to keep as a minimum distance between the two anchorsgoneMargin - How much margin we want to keep if the target is set to View.GONEpublic void connect(ConstraintAnchor from, ConstraintAnchor to, int margin)
from - the anchor we are connecting from (of this widget)to - the anchor we are connecting tomargin - how much margin we want to havepublic void connect(ConstraintAnchor.Type constraintFrom, ConstraintWidget target, ConstraintAnchor.Type constraintTo)
constraintFrom - which anchor of this widget to connect fromtarget - the target widgetconstraintTo - the target anchor on the target widgetpublic void connect(ConstraintAnchor.Type constraintFrom, ConstraintWidget target, ConstraintAnchor.Type constraintTo, int margin)
constraintFrom - which anchor of this widget to connect fromtarget - the target widgetconstraintTo - the target anchor on the target widgetmargin - how much margin we want to keep as a minimum distance between the two anchorspublic void resetAllConstraints()
public void resetAnchor(ConstraintAnchor anchor)
anchor - the anchor we want to resetpublic void resetAnchors()
public ConstraintAnchor getAnchor(ConstraintAnchor.Type anchorType)
anchorType - type of the anchor (LEFT, TOP, RIGHT, BOTTOM, BASELINE, CENTER_X, CENTER_Y)public ConstraintWidget.DimensionBehaviour getHorizontalDimensionBehaviour()
public ConstraintWidget.DimensionBehaviour getVerticalDimensionBehaviour()
public ConstraintWidget.DimensionBehaviour getDimensionBehaviour(int orientation)
ConstraintWidget.DimensionBehaviour in an specific orientation.orientation - ConstraintWidget.DimensionBehaviour of the widget.public void setHorizontalDimensionBehaviour(ConstraintWidget.DimensionBehaviour behaviour)
behaviour - the horizontal dimension's behaviourpublic void setVerticalDimensionBehaviour(ConstraintWidget.DimensionBehaviour behaviour)
behaviour - the vertical dimension's behaviourpublic boolean isInHorizontalChain()
public ConstraintWidget getPreviousChainMember(int orientation)
orientation - HORIZONTAL or VERTICALpublic ConstraintWidget getNextChainMember(int orientation)
orientation - HORIZONTAL or VERTICALpublic ConstraintWidget getHorizontalChainControlWidget()
public boolean isInVerticalChain()
public ConstraintWidget getVerticalChainControlWidget()
public void addToSolver(LinearSystem system, boolean optimize)
system - the solver we want to add the widget tooptimize - true if Optimizer.OPTIMIZATION_GRAPH is onpublic void setupDimensionRatio(boolean hParentWrapContent,
boolean vParentWrapContent,
boolean horizontalDimensionFixed,
boolean verticalDimensionFixed)
hParentWrapContent - true if parent is in wrap content horizontallyvParentWrapContent - true if parent is in wrap content verticallyhorizontalDimensionFixed - true if this widget horizontal dimension is fixedverticalDimensionFixed - true if this widget vertical dimension is fixedpublic void updateFromSolver(LinearSystem system, boolean optimize)
system - the solver we get the values from.optimize - true if Optimizer.OPTIMIZATION_GRAPH is onpublic void copy(ConstraintWidget src, java.util.HashMap<ConstraintWidget,ConstraintWidget> map)
public void updateFromRuns(boolean updateHorizontal,
boolean updateVertical)
public void addChildrenToSolverByDependency(ConstraintWidgetContainer container, LinearSystem system, java.util.HashSet<ConstraintWidget> widgets, int orientation, boolean addSelf)
public void getSceneString(java.lang.StringBuilder ret)