public class ConstraintSet


Defines a set of constraints to be used with ConstraintLayout.

ConstraintSet enables you create and save constraints and apply them to an existing ConstraintLayout. For details about constraint behaviour, see ConstraintLayout.

ConstraintsSet can be created in various ways:

  • Manually — c = new ConstraintSet(); c.connect(...);
  • From an R.layout.* object — c.clone(context, R.layout.layout1);
  • From a ConstraintLayoutc.clone(constraintLayout);

Example code:

import android.content.Context;
     import android.os.Bundle;
     import android.support.constraint.ConstraintLayout;
     import android.support.constraint.ConstraintSet;
     import android.support.transition.TransitionManager;
     import android.support.v7.app.AppCompatActivity;
     import android.view.View;

     public class MainActivity extends AppCompatActivity {
         ConstraintSet mConstraintSet1 = new ConstraintSet(); // Create a ConstraintSet.
         ConstraintSet mConstraintSet2 = new ConstraintSet(); // Create a ConstraintSet.
         ConstraintLayout mConstraintLayout; // Cache the ConstraintLayout.
         boolean mOld = true;


         protected void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             Context context = this;
             mConstraintSet2.clone(context, R.layout.state2); // Get constraints from layout.
             setContentView(R.layout.state1);
             mConstraintLayout = (ConstraintLayout) findViewById(R.id.activity_main);
             mConstraintSet1.clone(mConstraintLayout); // Get constraints from ConstraintSet.
         }

         public void foo(View view) {
             TransitionManager.beginDelayedTransition(mConstraintLayout);
             if (mOld = !mOld) {
                 mConstraintSet1.applyTo(mConstraintLayout); // Set new constraints.
             }  else {
                 mConstraintSet2.applyTo(mConstraintLayout); // Set new constraints.
             }
         }
     }

Summary

Nested types

Constants

static final int

The baseline of the text in a view.

static final int
BOTTOM = 4

The bottom side of a view.

static final int

Chain packed style

static final int

Chain spread style

static final int

Chain spread inside style

static final int

Circle reference from a view.

static final int
END = 7

The right side of a view in left to right languages.

static final int
GONE = 8

This view is gone, and will not take any space for layout purposes.

static final int

The horizontal orientation.

static final int

Used to create a horizontal create guidelines.

static final int

This view is invisible, but it still takes up space for layout purposes.

static final int
LEFT = 1

The left side of a view.

static final int

Dimension will be controlled by constraints

static final int
static final int

Calculate the size of a view in 0 dp by reducing the constrains gaps as much as possible

static final int

How to calculate the size of a view in 0 dp by using its wrap_content size

static final int

References the id of the parent.

static final int
RIGHT = 2

The right side of a view.

static final int
static final int
static final int
static final int
static final int
static final int
START = 6

The left side of a view in left to right languages.

static final int
TOP = 3

The top of a view.

static final int
UNSET = -1

Used to indicate a parameter is cleared or not set

static final int

The vertical orientation.

static final int

Used to create a vertical create guidelines. see create

static final int
static final int
static final int

This view is visible.

static final int

Dimension will set by the view's content

Public constructors

Public methods

void
addColorAttributes(String[] attributeName)

Add attribute of type Color

void
addFloatAttributes(String[] attributeName)

Add attribute of type float

void
addIntAttributes(String[] attributeName)

Add attribute of type Int

void
addStringAttributes(String[] attributeName)

Add attribute of type string

void
addToHorizontalChain(int viewId, int leftId, int rightId)

Adds a view to a horizontal chain.

void
addToHorizontalChainRTL(int viewId, int leftId, int rightId)

Adds a view to a horizontal chain.

void
addToVerticalChain(int viewId, int topId, int bottomId)

Adds a view to a vertical chain.

void

Apply custom attributes alone

void

Get the delta form the ConstraintSet and aplly to this

void
applyTo(ConstraintLayout constraintLayout)

Apply the constraints to a ConstraintLayout.

void
applyToHelper(
    ConstraintHelper helper,
    ConstraintWidget child,
    ConstraintLayout.LayoutParams layoutParams,
    SparseArray<ConstraintWidget> mapIdToWidget
)

Apply Layout to Helper widget

void

Fill in a ConstraintLayout LayoutParam based on the id.

void

Apply the constraints to a ConstraintLayout.

static ConstraintSet.Constraint
buildDelta(Context context, XmlPullParser parser)

Used to read a ConstraintDelta

void
center(
    int centerID,
    int firstID,
    int firstSide,
    int firstMargin,
    int secondId,
    int secondSide,
    int secondMargin,
    float bias
)

Center widget between the other two widgets.

void
centerHorizontally(int viewId, int toView)

Centers the view horizontally relative to toView's position.

void
centerHorizontally(
    int centerID,
    int leftId,
    int leftSide,
    int leftMargin,
    int rightId,
    int rightSide,
    int rightMargin,
    float bias
)

Centers the widget horizontally to the left and right side on another widgets sides.

void
centerHorizontallyRtl(int viewId, int toView)

Centers the view horizontally relative to toView's position.

void
centerHorizontallyRtl(
    int centerID,
    int startId,
    int startSide,
    int startMargin,
    int endId,
    int endSide,
    int endMargin,
    float bias
)

Centers the widgets horizontally to the left and right side on another widgets sides.

void
centerVertically(int viewId, int toView)

Centers the view vertically relative to toView's position.

void
centerVertically(
    int centerID,
    int topId,
    int topSide,
    int topMargin,
    int bottomId,
    int bottomSide,
    int bottomMargin,
    float bias
)

Centers the widgets vertically to the top and bottom side on another widgets sides.

void
clear(int viewId)

Remove all constraints from this view.

void
clear(int viewId, int anchor)

Remove a constraint from this view.

void
clone(ConstraintLayout constraintLayout)

Copy the layout parameters of a ConstraintLayout.

void
clone(Constraints constraints)

Copy the layout parameters of a ConstraintLayout.

void

Copy the constraints from a layout.

void
clone(Context context, int constraintLayoutId)

Copy the constraints from a layout.

void
connect(int startID, int startSide, int endID, int endSide)

Create a constraint between two widgets.

void
connect(int startID, int startSide, int endID, int endSide, int margin)

Create a constraint between two widgets.

void
constrainCircle(int viewId, int id, int radius, float angle)

Constrain the view on a circle constraint

void
constrainDefaultHeight(int viewId, int height)

Sets how the height is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD.

void
constrainDefaultWidth(int viewId, int width)

Sets how the width is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD.

void
constrainHeight(int viewId, int height)

Sets the height of the view.

void
constrainMaxHeight(int viewId, int height)

Sets the maximum height of the view.

void
constrainMaxWidth(int viewId, int width)

Sets the maximum width of the view.

void
constrainMinHeight(int viewId, int height)

Sets the height of the view.

void
constrainMinWidth(int viewId, int width)

Sets the width of the view.

void
constrainPercentHeight(int viewId, float percent)

Sets the height of the view as a percentage of the parent.

void
constrainPercentWidth(int viewId, float percent)

Sets the width of the view as a percentage of the parent.

void
constrainWidth(int viewId, int width)

Sets the width of the view.

void
constrainedHeight(int viewId, boolean constrained)

Sets how the height is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD.

void
constrainedWidth(int viewId, boolean constrained)

Sets how the width is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD.

void
create(int guidelineID, int orientation)

Creates a ConstraintLayout virtual object.

void
createBarrier(int id, int direction, int margin, int[] referenced)

Creates a ConstraintLayout Barrier object.

void
createHorizontalChain(
    int leftId,
    int leftSide,
    int rightId,
    int rightSide,
    int[] chainIds,
    float[] weights,
    int style
)

Spaces a set of widgets horizontally between the view startID and endId.

void
createHorizontalChainRtl(
    int startId,
    int startSide,
    int endId,
    int endSide,
    int[] chainIds,
    float[] weights,
    int style
)

Spaces a set of widgets horizontal between the view startID and endId.

void
createVerticalChain(
    int topId,
    int topSide,
    int bottomId,
    int bottomSide,
    int[] chainIds,
    float[] weights,
    int style
)

Spaces a set of widgets vertically between the view topId and bottomId.

void
dump(MotionScene scene, int[] ids)

Dump the contents

boolean
getApplyElevation(int viewId)

return with the constraint set will apply elevation for the specified view.

ConstraintSet.Constraint
getConstraint(int id)
HashMap<StringConstraintAttribute>
int
getHeight(int viewId)

Get the height set in the view

int[]
ConstraintSet.Constraint
getParameters(int mId)
int[]

get the reference id's of a helper.

String[]

Get the types associated with this ConstraintSet The types mechanism allows you to tag the constraint set with a series of string to define properties of a ConstraintSet

int
getVisibility(int viewId)

Get the visibility flag set in this view

int
getVisibilityMode(int viewId)

ConstraintSet will not setVisibility.

int
getWidth(int viewId)

Get the width set in the view

boolean

Enforce id are required for all ConstraintLayout children to use ConstraintSet. default = true;

boolean

If true perform validation checks when parsing ConstraintSets This will slow down parsing and should only be used for debugging

void
load(Context context, XmlPullParser parser)

Load a constraint set from a constraintSet.xml file

void
load(Context context, int resourceId)

Load a constraint set from a constraintSet.xml file.

boolean
matchesLabels(String[] types)

Test if the list of strings matches labels defined on this constraintSet

void

Parse color

void

Parse floats

void

Parse int

void

Parse string

void
readFallback(ConstraintLayout constraintLayout)

This will copy Constraints from the ConstraintLayout if it does not have parameters

void

This will copy Constraints from the ConstraintSet

void
removeAttribute(String attributeName)

Remove the attribute

void

Removes a view from a horizontal chain.

void

Removes a view from a vertical chain.

void
setAlpha(int viewId, float alpha)

Adjust the alpha of a view.

void
setApplyElevation(int viewId, boolean apply)

set if elevation will be applied to the view.

void
setBarrierType(int id, int type)

SEt tye type of barier

void
setColorValue(int viewId, String attributeName, int value)

Set the value of an attribute of type color

void
setDimensionRatio(int viewId, String ratio)

Constrains the views aspect ratio.

void
setEditorAbsoluteX(int viewId, int position)
void
setEditorAbsoluteY(int viewId, int position)
void
setElevation(int viewId, float elevation)

Adjust the elevation of a view.

void
setFloatValue(int viewId, String attributeName, float value)

Set the value of an attribute of type float

void
setForceId(boolean forceId)

Enforce id are required for all ConstraintLayout children to use ConstraintSet. default = true;

void
setGoneMargin(int viewId, int anchor, int value)

Sets the gone margin.

void
setGuidelineBegin(int guidelineID, int margin)

Set the guideline's distance form the top or left edge.

void
setGuidelineEnd(int guidelineID, int margin)

Set a guideline's distance to end.

void
setGuidelinePercent(int guidelineID, float ratio)

Set a Guideline's percent.

void
setHorizontalBias(int viewId, float bias)

Adjust the horizontal bias of the view (used with views constrained on left and right).

void
setHorizontalChainStyle(int viewId, int chainStyle)

How the elements of the horizontal chain will be positioned. if the dimension behaviour is set to MATCH_CONSTRAINT.

void
setHorizontalWeight(int viewId, float weight)

The child's weight that we can use to distribute the available horizontal space in a chain, if the dimension behaviour is set to MATCH_CONSTRAINT

void
setIntValue(int viewId, String attributeName, int value)

Set the value of an attribute of type int

void
setLayoutWrapBehavior(int viewId, int behavior)

Sets the wrap behavior of the widget in the parent's wrap computation

void
setMargin(int viewId, int anchor, int value)

Sets the margin.

void
setReferencedIds(int id, int[] referenced)

sets the reference id's of a barrier.

void
setRotation(int viewId, float rotation)

Adjust the post-layout rotation about the Z axis of a view.

void
setRotationX(int viewId, float rotationX)

Adjust the post-layout rotation about the X axis of a view.

void
setRotationY(int viewId, float rotationY)

Adjust the post-layout rotation about the Y axis of a view.

void
setScaleX(int viewId, float scaleX)

Adjust the post-layout scale in X of a view.

void
setScaleY(int viewId, float scaleY)

Adjust the post-layout scale in Y of a view.

void

Set the types associated with this ConstraintSet The types mechanism allows you to tag the constraint set with a series of string to define properties of a ConstraintSet

void
setStateLabelsList(String[] types)

Set the types associated with this ConstraintSet The types mechanism allows you to tag the constraint set with a series of string to define properties of a ConstraintSet

void
setStringValue(int viewId, String attributeName, String value)

Set the value of an attribute of type string

void
setTransformPivot(
    int viewId,
    float transformPivotX,
    float transformPivotY
)

Set X,Y location of the pivot point around which the view will rotate and scale. use Float.NaN to clear the pivot value.

void
setTransformPivotX(int viewId, float transformPivotX)

Set X location of the pivot point around which the view will rotate and scale. use Float.NaN to clear the pivot value.

void
setTransformPivotY(int viewId, float transformPivotY)

Set Y location of the pivot point around which the view will rotate and scale. use Float.NaN to clear the pivot value.

void
setTranslation(int viewId, float translationX, float translationY)

Adjust the post-layout translation of a view.

void
setTranslationX(int viewId, float translationX)

Adjust the post-layout X translation of a view.

void
setTranslationY(int viewId, float translationY)

Adjust the post-layout Y translation of a view.

void
setTranslationZ(int viewId, float translationZ)

Adjust the translation in Z of a view.

void
setValidateOnParse(boolean validate)

If true perform validation checks when parsing ConstraintSets This will slow down parsing and should only be used for debugging

void
setVerticalBias(int viewId, float bias)

Adjust the vertical bias of the view (used with views constrained on left and right).

void
setVerticalChainStyle(int viewId, int chainStyle)

How the elements of the vertical chain will be positioned. in a chain, if the dimension behaviour is set to MATCH_CONSTRAINT

void
setVerticalWeight(int viewId, float weight)

The child's weight that we can use to distribute the available vertical space in a chain, if the dimension behaviour is set to MATCH_CONSTRAINT

void
setVisibility(int viewId, int visibility)

Adjust the visibility of a view.

void
setVisibilityMode(int viewId, int visibilityMode)

ConstraintSet will not setVisibility.

void
writeState(Writer writer, ConstraintLayout layout, int flags)

Write the state to a Writer

Constants

BASELINE

Added in 2.2.0-alpha13
public static final int BASELINE = 5

The baseline of the text in a view.

BOTTOM

Added in 2.2.0-alpha13
public static final int BOTTOM = 4

The bottom side of a view.

CHAIN_PACKED

Added in 2.2.0-alpha13
public static final int CHAIN_PACKED = 2

Chain packed style

CHAIN_SPREAD

Added in 2.2.0-alpha13
public static final int CHAIN_SPREAD = 0

Chain spread style

CHAIN_SPREAD_INSIDE

Added in 2.2.0-alpha13
public static final int CHAIN_SPREAD_INSIDE = 1

Chain spread inside style

CIRCLE_REFERENCE

Added in 2.2.0-alpha13
public static final int CIRCLE_REFERENCE = 8

Circle reference from a view.

END

Added in 2.2.0-alpha13
public static final int END = 7

The right side of a view in left to right languages. In right to left languages it corresponds to the left side of the view

GONE

Added in 2.2.0-alpha13
public static final int GONE = 8

This view is gone, and will not take any space for layout purposes. Use with setVisibility and android:visibility.

HORIZONTAL

Added in 2.2.0-alpha13
public static final int HORIZONTAL = 0

The horizontal orientation.

HORIZONTAL_GUIDELINE

Added in 2.2.0-alpha13
public static final int HORIZONTAL_GUIDELINE = 0

Used to create a horizontal create guidelines.

INVISIBLE

Added in 2.2.0-alpha13
public static final int INVISIBLE = 4

This view is invisible, but it still takes up space for layout purposes. Use with setVisibility and android:visibility.

LEFT

Added in 2.2.0-alpha13
public static final int LEFT = 1

The left side of a view.

MATCH_CONSTRAINT

Added in 2.2.0-alpha13
public static final int MATCH_CONSTRAINT = 0

Dimension will be controlled by constraints

MATCH_CONSTRAINT_PERCENT

Added in 2.2.0-alpha13
public static final int MATCH_CONSTRAINT_PERCENT = 2

MATCH_CONSTRAINT_SPREAD

Added in 2.2.0-alpha13
public static final int MATCH_CONSTRAINT_SPREAD = 0

Calculate the size of a view in 0 dp by reducing the constrains gaps as much as possible

MATCH_CONSTRAINT_WRAP

Added in 2.2.0-alpha13
public static final int MATCH_CONSTRAINT_WRAP = 1

How to calculate the size of a view in 0 dp by using its wrap_content size

PARENT_ID

Added in 2.2.0-alpha13
public static final int PARENT_ID = 0

References the id of the parent. Used in:

RIGHT

Added in 2.2.0-alpha13
public static final int RIGHT = 2

The right side of a view.

ROTATE_LEFT_OF_PORTRATE

Added in 2.2.0-alpha13
public static final int ROTATE_LEFT_OF_PORTRATE = 4

ROTATE_NONE

Added in 2.2.0-alpha13
public static final int ROTATE_NONE = 0

ROTATE_PORTRATE_OF_LEFT

Added in 2.2.0-alpha13
public static final int ROTATE_PORTRATE_OF_LEFT = 2

ROTATE_PORTRATE_OF_RIGHT

Added in 2.2.0-alpha13
public static final int ROTATE_PORTRATE_OF_RIGHT = 1

ROTATE_RIGHT_OF_PORTRATE

Added in 2.2.0-alpha13
public static final int ROTATE_RIGHT_OF_PORTRATE = 3

START

Added in 2.2.0-alpha13
public static final int START = 6

The left side of a view in left to right languages. In right to left languages it corresponds to the right side of the view

TOP

Added in 2.2.0-alpha13
public static final int TOP = 3

The top of a view.

UNSET

Added in 2.2.0-alpha13
public static final int UNSET = -1

Used to indicate a parameter is cleared or not set

VERTICAL

Added in 2.2.0-alpha13
public static final int VERTICAL = 1

The vertical orientation.

VERTICAL_GUIDELINE

Added in 2.2.0-alpha13
public static final int VERTICAL_GUIDELINE = 1

Used to create a vertical create guidelines. see create

VISIBILITY_MODE_IGNORE

Added in 2.2.0-alpha13
public static final int VISIBILITY_MODE_IGNORE = 1

VISIBILITY_MODE_NORMAL

Added in 2.2.0-alpha13
public static final int VISIBILITY_MODE_NORMAL = 0

VISIBLE

Added in 2.2.0-alpha13
public static final int VISIBLE = 0

This view is visible. Use with setVisibility and android:visibility.

WRAP_CONTENT

Added in 2.2.0-alpha13
public static final int WRAP_CONTENT = -2

Dimension will set by the view's content

Public fields

derivedState

Added in 2.2.0-alpha13
public String derivedState

mIdString

Added in 2.2.0-alpha13
public String mIdString

mRotate

Added in 2.2.0-alpha13
public int mRotate

Public constructors

ConstraintSet

Added in 2.2.0-alpha13
public ConstraintSet()

Public methods

addColorAttributes

public void addColorAttributes(String[] attributeName)

Add attribute of type Color

Parameters
String[] attributeName

addFloatAttributes

public void addFloatAttributes(String[] attributeName)

Add attribute of type float

Parameters
String[] attributeName

addIntAttributes

public void addIntAttributes(String[] attributeName)

Add attribute of type Int

Parameters
String[] attributeName

addStringAttributes

public void addStringAttributes(String[] attributeName)

Add attribute of type string

Parameters
String[] attributeName

addToHorizontalChain

Added in 2.2.0-alpha13
public void addToHorizontalChain(int viewId, int leftId, int rightId)

Adds a view to a horizontal chain.

Parameters
int viewId

view to add

int leftId

view in chain to the left

int rightId

view in chain to the right

addToHorizontalChainRTL

Added in 2.2.0-alpha13
public void addToHorizontalChainRTL(int viewId, int leftId, int rightId)

Adds a view to a horizontal chain.

Parameters
int viewId

view to add

int leftId

view to the start side

int rightId

view to the end side

addToVerticalChain

Added in 2.2.0-alpha13
public void addToVerticalChain(int viewId, int topId, int bottomId)

Adds a view to a vertical chain.

Parameters
int viewId

view to add to a vertical chain

int topId

view above.

int bottomId

view below

applyCustomAttributes

Added in 2.2.0-alpha13
public void applyCustomAttributes(ConstraintLayout constraintLayout)

Apply custom attributes alone

Parameters
ConstraintLayout constraintLayout

applyDeltaFrom

Added in 2.2.0-alpha13
public void applyDeltaFrom(ConstraintSet cs)

Get the delta form the ConstraintSet and aplly to this

Parameters
ConstraintSet cs

applyTo

Added in 2.2.0-alpha13
public void applyTo(ConstraintLayout constraintLayout)

Apply the constraints to a ConstraintLayout.

Parameters
ConstraintLayout constraintLayout

to be modified

applyToHelper

Added in 2.2.0-alpha13
public void applyToHelper(
    ConstraintHelper helper,
    ConstraintWidget child,
    ConstraintLayout.LayoutParams layoutParams,
    SparseArray<ConstraintWidget> mapIdToWidget
)

Apply Layout to Helper widget

Parameters
ConstraintHelper helper
ConstraintWidget child
ConstraintLayout.LayoutParams layoutParams
SparseArray<ConstraintWidget> mapIdToWidget

applyToLayoutParams

Added in 2.2.0-alpha13
public void applyToLayoutParams(int id, ConstraintLayout.LayoutParams layoutParams)

Fill in a ConstraintLayout LayoutParam based on the id.

Parameters
int id

Id of the view

ConstraintLayout.LayoutParams layoutParams

LayoutParams to be filled

applyToWithoutCustom

Added in 2.2.0-alpha13
public void applyToWithoutCustom(ConstraintLayout constraintLayout)

Apply the constraints to a ConstraintLayout.

Parameters
ConstraintLayout constraintLayout

to be modified

buildDelta

Added in 2.2.0-alpha13
public static ConstraintSet.Constraint buildDelta(Context context, XmlPullParser parser)

Used to read a ConstraintDelta

Parameters
Context context
XmlPullParser parser

center

Added in 2.2.0-alpha13
public void center(
    int centerID,
    int firstID,
    int firstSide,
    int firstMargin,
    int secondId,
    int secondSide,
    int secondMargin,
    float bias
)

Center widget between the other two widgets. (for sides see: TOP, BOTTOM, START, END, LEFT, RIGHT) Note, sides must be all vertical or horizontal sides.

Parameters
int centerID

ID of the widget to be centered

int firstID

ID of the first widget to connect the left or top of the widget to

int firstSide

the side of the widget to connect to

int firstMargin

the connection margin

int secondId

the ID of the second widget to connect to right or top of the widget to

int secondSide

the side of the widget to connect to

int secondMargin

the connection margin

float bias

the ratio between two connections

centerHorizontally

Added in 2.2.0-alpha13
public void centerHorizontally(int viewId, int toView)

Centers the view horizontally relative to toView's position.

Parameters
int viewId

ID of view to center Horizontally

int toView

ID of view to center on (or in)

centerHorizontally

Added in 2.2.0-alpha13
public void centerHorizontally(
    int centerID,
    int leftId,
    int leftSide,
    int leftMargin,
    int rightId,
    int rightSide,
    int rightMargin,
    float bias
)

Centers the widget horizontally to the left and right side on another widgets sides. (for sides see: START, END, LEFT, RIGHT)

Parameters
int centerID

ID of widget to be centered

int leftId

The Id of the widget on the left side

int leftSide

The side of the leftId widget to connect to

int leftMargin

The margin on the left side

int rightId

The Id of the widget on the right side

int rightSide

The side of the rightId widget to connect to

int rightMargin

The margin on the right side

float bias

The ratio of the space on the left vs. right sides 0.5 is centered (default)

centerHorizontallyRtl

Added in 2.2.0-alpha13
public void centerHorizontallyRtl(int viewId, int toView)

Centers the view horizontally relative to toView's position.

Parameters
int viewId

ID of view to center Horizontally

int toView

ID of view to center on (or in)

centerHorizontallyRtl

Added in 2.2.0-alpha13
public void centerHorizontallyRtl(
    int centerID,
    int startId,
    int startSide,
    int startMargin,
    int endId,
    int endSide,
    int endMargin,
    float bias
)

Centers the widgets horizontally to the left and right side on another widgets sides. (for sides see: START, END, LEFT, RIGHT)

Parameters
int centerID

ID of widget to be centered

int startId

The Id of the widget on the start side (left in non rtl languages)

int startSide

The side of the startId widget to connect to

int startMargin

The margin on the start side

int endId

The Id of the widget on the start side (left in non rtl languages)

int endSide

The side of the endId widget to connect to

int endMargin

The margin on the end side

float bias

The ratio of the space on the start vs end side 0.5 is centered (default)

centerVertically

Added in 2.2.0-alpha13
public void centerVertically(int viewId, int toView)

Centers the view vertically relative to toView's position.

Parameters
int viewId

ID of view to center Horizontally

int toView

ID of view to center on (or in)

centerVertically

Added in 2.2.0-alpha13
public void centerVertically(
    int centerID,
    int topId,
    int topSide,
    int topMargin,
    int bottomId,
    int bottomSide,
    int bottomMargin,
    float bias
)

Centers the widgets vertically to the top and bottom side on another widgets sides. (for sides see: TOP, BOTTOM)

Parameters
int centerID

ID of widget to be centered

int topId

The Id of the widget on the top side

int topSide

The side of the leftId widget to connect to

int topMargin

The margin on the top side

int bottomId

The Id of the widget on the bottom side

int bottomSide

The side of the bottomId widget to connect to

int bottomMargin

The margin on the bottom side

float bias

The ratio of the space on the top vs. bottom sides 0.5 is centered (default)

clear

Added in 2.2.0-alpha13
public void clear(int viewId)

Remove all constraints from this view.

Parameters
int viewId

ID of view to remove all connections to

clear

Added in 2.2.0-alpha13
public void clear(int viewId, int anchor)

Remove a constraint from this view.

Parameters
int viewId

ID of view to center on (or in)

int anchor

the Anchor to remove constraint from

clone

Added in 2.2.0-alpha13
public void clone(ConstraintLayout constraintLayout)

Copy the layout parameters of a ConstraintLayout.

Parameters
ConstraintLayout constraintLayout

The ConstraintLayout to be copied

clone

Added in 2.2.0-alpha13
public void clone(Constraints constraints)

Copy the layout parameters of a ConstraintLayout.

Parameters
Constraints constraints

The ConstraintLayout to be copied

clone

Added in 2.2.0-alpha13
public void clone(ConstraintSet set)

Copy the constraints from a layout.

Parameters
ConstraintSet set

constraint set to copy

clone

Added in 2.2.0-alpha13
public void clone(Context context, int constraintLayoutId)

Copy the constraints from a layout.

Parameters
Context context

the context for the layout inflation

int constraintLayoutId

the id of the layout file

connect

Added in 2.2.0-alpha13
public void connect(int startID, int startSide, int endID, int endSide)

Create a constraint between two widgets. (for sides see: TOP, BOTTOM, START, END, LEFT, RIGHT, BASELINE)

Parameters
int startID

the ID of the widget to be constrained

int startSide

the side of the widget to constrain

int endID

the id of the widget to constrain to

int endSide

the side of widget to constrain to

connect

Added in 2.2.0-alpha13
public void connect(int startID, int startSide, int endID, int endSide, int margin)

Create a constraint between two widgets. (for sides see: TOP, BOTTOM, START, END, LEFT, RIGHT, BASELINE)

Parameters
int startID

the ID of the widget to be constrained

int startSide

the side of the widget to constrain

int endID

the id of the widget to constrain to

int endSide

the side of widget to constrain to

int margin

the margin to constrain (margin must be positive)

constrainCircle

Added in 2.2.0-alpha13
public void constrainCircle(int viewId, int id, int radius, float angle)

Constrain the view on a circle constraint

1.1

Parameters
int viewId

ID of the view we constrain

int id

ID of the view we constrain relative to

int radius

the radius of the circle in degrees

float angle

the angle

constrainDefaultHeight

Added in 2.2.0-alpha13
public void constrainDefaultHeight(int viewId, int height)

Sets how the height is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD. Default is spread.

1.1

Parameters
int viewId

ID of view to adjust its matchConstraintDefaultHeight

int height

MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD

constrainDefaultWidth

Added in 2.2.0-alpha13
public void constrainDefaultWidth(int viewId, int width)

Sets how the width is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD. Default is spread.

1.1

Parameters
int viewId

ID of view to adjust its matchConstraintDefaultWidth

int width

SPREAD or WRAP

constrainHeight

Added in 2.2.0-alpha13
public void constrainHeight(int viewId, int height)

Sets the height of the view. It can be a dimension, WRAP_CONTENT or MATCH_CONSTRAINT.

1.1

Parameters
int viewId

ID of view to adjust its height

int height

the height of the view

constrainMaxHeight

Added in 2.2.0-alpha13
public void constrainMaxHeight(int viewId, int height)

Sets the maximum height of the view. It is a dimension, It is only applicable if height is #MATCH_CONSTRAINT}.

1.1

Parameters
int viewId

ID of view to adjust it height

int height

the maximum height of the constraint

constrainMaxWidth

Added in 2.2.0-alpha13
public void constrainMaxWidth(int viewId, int width)

Sets the maximum width of the view. It is a dimension, It is only applicable if width is #MATCH_CONSTRAINT}.

1.1

Parameters
int viewId

ID of view to adjust its max height

int width

the maximum width of the view

constrainMinHeight

Added in 2.2.0-alpha13
public void constrainMinHeight(int viewId, int height)

Sets the height of the view. It is a dimension, It is only applicable if height is #MATCH_CONSTRAINT}.

1.1

Parameters
int viewId

ID of view to adjust its min height

int height

the minimum height of the view

constrainMinWidth

Added in 2.2.0-alpha13
public void constrainMinWidth(int viewId, int width)

Sets the width of the view. It is a dimension, It is only applicable if width is #MATCH_CONSTRAINT}.

1.1

Parameters
int viewId

ID of view to adjust its min height

int width

the minimum width of the view

constrainPercentHeight

Added in 2.2.0-alpha13
public void constrainPercentHeight(int viewId, float percent)

Sets the height of the view as a percentage of the parent.

1.1

Parameters
int viewId
float percent

constrainPercentWidth

Added in 2.2.0-alpha13
public void constrainPercentWidth(int viewId, float percent)

Sets the width of the view as a percentage of the parent.

1.1

Parameters
int viewId
float percent

constrainWidth

Added in 2.2.0-alpha13
public void constrainWidth(int viewId, int width)

Sets the width of the view. It can be a dimension, WRAP_CONTENT or MATCH_CONSTRAINT.

1.1

Parameters
int viewId

ID of view to adjust its width

int width

the width of the view

constrainedHeight

Added in 2.2.0-alpha13
public void constrainedHeight(int viewId, boolean constrained)

Sets how the height is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD. Default is spread.

1.1

Parameters
int viewId

ID of view to adjust its matchConstraintDefaultHeight

boolean constrained

if true height will be constrained

constrainedWidth

Added in 2.2.0-alpha13
public void constrainedWidth(int viewId, boolean constrained)

Sets how the width is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD. Default is spread.

1.1

Parameters
int viewId

ID of view to adjust its matchConstraintDefaultWidth

boolean constrained

if true with will be constrained

create

Added in 2.2.0-alpha13
public void create(int guidelineID, int orientation)

Creates a ConstraintLayout virtual object. Currently only horizontal or vertical GuideLines.

Parameters
int guidelineID

ID of guideline to create

int orientation

the Orientation of the guideline

createBarrier

public void createBarrier(int id, int direction, int margin, int[] referenced)

Creates a ConstraintLayout Barrier object.

1.1

Parameters
int id
int direction

Barrier.{LEFT,RIGHT,TOP,BOTTOM,START,END}

int[] referenced

createHorizontalChain

Added in 2.2.0-alpha13
public void createHorizontalChain(
    int leftId,
    int leftSide,
    int rightId,
    int rightSide,
    int[] chainIds,
    float[] weights,
    int style
)

Spaces a set of widgets horizontally between the view startID and endId. Widgets can be spaced with weights. This operation sets all the related margins to 0.

(for sides see: START, END, LEFT, RIGHT)

Parameters
int leftId

The id of the widget to connect to or PARENT_ID

int leftSide

the side of the start to connect to

int rightId

The id of the widget to connect to or PARENT_ID

int rightSide

the side of the right to connect to

int[] chainIds

The widgets in the chain

float[] weights

The weight to assign to each element in the chain or null

int style

The type of chain

createHorizontalChainRtl

Added in 2.2.0-alpha13
public void createHorizontalChainRtl(
    int startId,
    int startSide,
    int endId,
    int endSide,
    int[] chainIds,
    float[] weights,
    int style
)

Spaces a set of widgets horizontal between the view startID and endId. Widgets can be spaced with weights. (for sides see: START, END, LEFT, RIGHT)

Parameters
int startId

The id of the widget to connect to or PARENT_ID

int startSide

the side of the start to connect to

int endId

The id of the widget to connect to or PARENT_ID

int endSide

the side of the end to connect to

int[] chainIds

The widgets in the chain

float[] weights

The weight to assign to each element in the chain or null

int style

The type of chain

createVerticalChain

Added in 2.2.0-alpha13
public void createVerticalChain(
    int topId,
    int topSide,
    int bottomId,
    int bottomSide,
    int[] chainIds,
    float[] weights,
    int style
)

Spaces a set of widgets vertically between the view topId and bottomId. Widgets can be spaced with weights. This operation sets all the related margins to 0.

(for sides see: TOP, BOTTOM)

Parameters
int topId

The id of the widget to connect to or PARENT_ID

int topSide

the side of the start to connect to

int bottomId

The id of the widget to connect to or PARENT_ID

int bottomSide

the side of the right to connect to

int[] chainIds

widgets to use as a chain

float[] weights

can be null

int style

set the style of the chain

dump

public void dump(MotionScene scene, int[] ids)

Dump the contents

Parameters
MotionScene scene
int[] ids

getApplyElevation

Added in 2.2.0-alpha13
public boolean getApplyElevation(int viewId)

return with the constraint set will apply elevation for the specified view.

Returns
boolean

true if the elevation will be set on this view (default is false)

getConstraint

Added in 2.2.0-alpha13
public ConstraintSet.Constraint getConstraint(int id)

getCustomAttributeSet

Added in 2.2.0-alpha13
public HashMap<StringConstraintAttributegetCustomAttributeSet()

getHeight

Added in 2.2.0-alpha13
public int getHeight(int viewId)

Get the height set in the view

Parameters
int viewId

the id of the view

Returns
int

return the height constraint of the view

getKnownIds

Added in 2.2.0-alpha13
public int[] getKnownIds()

getParameters

Added in 2.2.0-alpha13
public ConstraintSet.Constraint getParameters(int mId)
Parameters
int mId

getReferencedIds

Added in 2.2.0-alpha13
public int[] getReferencedIds(int id)

get the reference id's of a helper.

Parameters
int id
Returns
int[]

array of id's

getStateLabels

Added in 2.2.0-alpha13
public String[] getStateLabels()

Get the types associated with this ConstraintSet The types mechanism allows you to tag the constraint set with a series of string to define properties of a ConstraintSet

Returns
String[]

an array of type strings

getVisibility

Added in 2.2.0-alpha13
public int getVisibility(int viewId)

Get the visibility flag set in this view

Parameters
int viewId

the id of the view

Returns
int

the visibility constraint for the view

getVisibilityMode

Added in 2.2.0-alpha13
public int getVisibilityMode(int viewId)

ConstraintSet will not setVisibility. VISIBILITY_MODE_IGNORE or VISIBILITY_MODE_NORMAL.

Parameters
int viewId

ID of view

getWidth

Added in 2.2.0-alpha13
public int getWidth(int viewId)

Get the width set in the view

Parameters
int viewId

the id of the view

Returns
int

return the width constraint of the view

isForceId

Added in 2.2.0-alpha13
public boolean isForceId()

Enforce id are required for all ConstraintLayout children to use ConstraintSet. default = true;

isValidateOnParse

Added in 2.2.0-alpha13
public boolean isValidateOnParse()

If true perform validation checks when parsing ConstraintSets This will slow down parsing and should only be used for debugging

Returns
boolean

validate

load

Added in 2.2.0-alpha13
public void load(Context context, XmlPullParser parser)

Load a constraint set from a constraintSet.xml file

Parameters
Context context

the context for the inflation

XmlPullParser parser

id of xml file in res/xml/

load

Added in 2.2.0-alpha13
public void load(Context context, int resourceId)

Load a constraint set from a constraintSet.xml file. Note. Do NOT use this to load a layout file. It will fail silently as there is no efficient way to differentiate.

Parameters
Context context

the context for the inflation

int resourceId

id of xml file in res/xml/

matchesLabels

public boolean matchesLabels(String[] types)

Test if the list of strings matches labels defined on this constraintSet

Parameters
String[] types

list of types

Returns
boolean

true if all types are in the labels

parseColorAttributes

Added in 2.2.0-alpha13
public void parseColorAttributes(ConstraintSet.Constraint set, String attributes)

Parse color

Parameters
ConstraintSet.Constraint set
String attributes

parseFloatAttributes

Added in 2.2.0-alpha13
public void parseFloatAttributes(ConstraintSet.Constraint set, String attributes)

Parse floats

Parameters
ConstraintSet.Constraint set
String attributes

parseIntAttributes

Added in 2.2.0-alpha13
public void parseIntAttributes(ConstraintSet.Constraint set, String attributes)

Parse int

Parameters
ConstraintSet.Constraint set
String attributes

parseStringAttributes

Added in 2.2.0-alpha13
public void parseStringAttributes(ConstraintSet.Constraint set, String attributes)

Parse string

Parameters
ConstraintSet.Constraint set
String attributes

readFallback

Added in 2.2.0-alpha13
public void readFallback(ConstraintLayout constraintLayout)

This will copy Constraints from the ConstraintLayout if it does not have parameters

Parameters
ConstraintLayout constraintLayout

readFallback

Added in 2.2.0-alpha13
public void readFallback(ConstraintSet set)

This will copy Constraints from the ConstraintSet

Parameters
ConstraintSet set

removeAttribute

Added in 2.2.0-alpha13
public void removeAttribute(String attributeName)

Remove the attribute

Parameters
String attributeName

removeFromHorizontalChain

Added in 2.2.0-alpha13
public void removeFromHorizontalChain(int viewId)

Removes a view from a horizontal chain. This assumes the view is connected to a horizontal chain. Its behaviour is undefined if not part of a horizontal chain.

Parameters
int viewId

the view to be removed

removeFromVerticalChain

Added in 2.2.0-alpha13
public void removeFromVerticalChain(int viewId)

Removes a view from a vertical chain. This assumes the view is connected to a vertical chain. Its behaviour is undefined if not part of a vertical chain.

Parameters
int viewId

the view to be removed

setAlpha

Added in 2.2.0-alpha13
public void setAlpha(int viewId, float alpha)

Adjust the alpha of a view.

Parameters
int viewId

ID of view to adjust the vertical

float alpha

the alpha

setApplyElevation

Added in 2.2.0-alpha13
public void setApplyElevation(int viewId, boolean apply)

set if elevation will be applied to the view. Elevation logic is based on style and animation. By default it is not used because it would lead to unexpected results.

Parameters
boolean apply

true if this constraint set applies elevation to this view

setBarrierType

Added in 2.2.0-alpha13
public void setBarrierType(int id, int type)

SEt tye type of barier

Parameters
int id
int type

setColorValue

Added in 2.2.0-alpha13
public void setColorValue(int viewId, String attributeName, int value)

Set the value of an attribute of type color

Parameters
int viewId
String attributeName
int value

setDimensionRatio

Added in 2.2.0-alpha13
public void setDimensionRatio(int viewId, String ratio)

Constrains the views aspect ratio. For Example a HD screen is 16 by 9 = 16/(float)9 = 1.777f.

Parameters
int viewId

ID of view to constrain

String ratio

The ratio of the width to height (width / height)

setEditorAbsoluteX

Added in 2.2.0-alpha13
public void setEditorAbsoluteX(int viewId, int position)

setEditorAbsoluteY

Added in 2.2.0-alpha13
public void setEditorAbsoluteY(int viewId, int position)

setElevation

Added in 2.2.0-alpha13
public void setElevation(int viewId, float elevation)

Adjust the elevation of a view.

Parameters
int viewId

ID of view to adjust the elevation

float elevation

the elevation

setFloatValue

Added in 2.2.0-alpha13
public void setFloatValue(int viewId, String attributeName, float value)

Set the value of an attribute of type float

Parameters
int viewId
String attributeName
float value

setForceId

Added in 2.2.0-alpha13
public void setForceId(boolean forceId)

Enforce id are required for all ConstraintLayout children to use ConstraintSet. default = true;

Parameters
boolean forceId

setGoneMargin

Added in 2.2.0-alpha13
public void setGoneMargin(int viewId, int anchor, int value)

Sets the gone margin.

Parameters
int viewId

ID of view to adjust the margin on

int anchor

The side to adjust the margin on

int value

The new value for the margin

setGuidelineBegin

Added in 2.2.0-alpha13
public void setGuidelineBegin(int guidelineID, int margin)

Set the guideline's distance form the top or left edge.

Parameters
int guidelineID

ID of the guideline

int margin

the distance to the top or left edge

setGuidelineEnd

Added in 2.2.0-alpha13
public void setGuidelineEnd(int guidelineID, int margin)

Set a guideline's distance to end.

Parameters
int guidelineID

ID of the guideline

int margin

the margin to the right or bottom side of container

setGuidelinePercent

Added in 2.2.0-alpha13
public void setGuidelinePercent(int guidelineID, float ratio)

Set a Guideline's percent.

Parameters
int guidelineID

ID of the guideline

float ratio

the ratio between the gap on the left and right 0.0 is top/left 0.5 is middle

setHorizontalBias

Added in 2.2.0-alpha13
public void setHorizontalBias(int viewId, float bias)

Adjust the horizontal bias of the view (used with views constrained on left and right).

Parameters
int viewId

ID of view to adjust the horizontal

float bias

the new bias 0.5 is in the middle

setHorizontalChainStyle

Added in 2.2.0-alpha13
public void setHorizontalChainStyle(int viewId, int chainStyle)

How the elements of the horizontal chain will be positioned. if the dimension behaviour is set to MATCH_CONSTRAINT. The possible values are:

  • CHAIN_SPREAD -- the elements will be spread out
  • CHAIN_SPREAD_INSIDE -- similar, but the endpoints of the chain will not be spread out
  • CHAIN_PACKED -- the elements of the chain will be packed together. The horizontal bias attribute of the child will then affect the positioning of the packed elements
Parameters
int viewId

ID of view to adjust its HorizontalChainStyle

int chainStyle

the weight that we can use to distribute the horizontal space

setHorizontalWeight

Added in 2.2.0-alpha13
public void setHorizontalWeight(int viewId, float weight)

The child's weight that we can use to distribute the available horizontal space in a chain, if the dimension behaviour is set to MATCH_CONSTRAINT

Parameters
int viewId

ID of view to adjust its HorizontalWeight

float weight

the weight that we can use to distribute the horizontal space

setIntValue

Added in 2.2.0-alpha13
public void setIntValue(int viewId, String attributeName, int value)

Set the value of an attribute of type int

Parameters
int viewId
String attributeName
int value

setLayoutWrapBehavior

Added in 2.2.0-alpha13
public void setLayoutWrapBehavior(int viewId, int behavior)

Sets the wrap behavior of the widget in the parent's wrap computation

setMargin

Added in 2.2.0-alpha13
public void setMargin(int viewId, int anchor, int value)

Sets the margin.

Parameters
int viewId

ID of view to adjust the margin on

int anchor

The side to adjust the margin on

int value

The new value for the margin

setReferencedIds

public void setReferencedIds(int id, int[] referenced)

sets the reference id's of a barrier.

2.0

Parameters
int id
int[] referenced

setRotation

Added in 2.2.0-alpha13
public void setRotation(int viewId, float rotation)

Adjust the post-layout rotation about the Z axis of a view.

Parameters
int viewId

ID of view to adjust th Z rotation

float rotation

the rotation about the X axis

setRotationX

Added in 2.2.0-alpha13
public void setRotationX(int viewId, float rotationX)

Adjust the post-layout rotation about the X axis of a view.

Parameters
int viewId

ID of view to adjust th X rotation

float rotationX

the rotation about the X axis

setRotationY

Added in 2.2.0-alpha13
public void setRotationY(int viewId, float rotationY)

Adjust the post-layout rotation about the Y axis of a view.

Parameters
int viewId

ID of view to adjust the Y rotation

float rotationY

the rotationY

setScaleX

Added in 2.2.0-alpha13
public void setScaleX(int viewId, float scaleX)

Adjust the post-layout scale in X of a view.

Parameters
int viewId

ID of view to adjust the scale in X

float scaleX

the scale in X

setScaleY

Added in 2.2.0-alpha13
public void setScaleY(int viewId, float scaleY)

Adjust the post-layout scale in Y of a view.

Parameters
int viewId

ID of view to adjust the scale in Y

float scaleY

the scale in Y

setStateLabels

Added in 2.2.0-alpha13
public void setStateLabels(String types)

Set the types associated with this ConstraintSet The types mechanism allows you to tag the constraint set with a series of string to define properties of a ConstraintSet

Parameters
String types

a comer separated array of strings.

setStateLabelsList

public void setStateLabelsList(String[] types)

Set the types associated with this ConstraintSet The types mechanism allows you to tag the constraint set with a series of string to define properties of a ConstraintSet

Parameters
String[] types

a comer separated array of strings.

setStringValue

Added in 2.2.0-alpha13
public void setStringValue(int viewId, String attributeName, String value)

Set the value of an attribute of type string

Parameters
int viewId
String attributeName
String value

setTransformPivot

Added in 2.2.0-alpha13
public void setTransformPivot(
    int viewId,
    float transformPivotX,
    float transformPivotY
)

Set X,Y location of the pivot point around which the view will rotate and scale. use Float.NaN to clear the pivot value. Note: once an actual View has had its pivot set it cannot be cleared.

Parameters
int viewId

ID of view to adjust the transforms pivot point

float transformPivotX

X location of the pivot point.

float transformPivotY

Y location of the pivot point.

setTransformPivotX

Added in 2.2.0-alpha13
public void setTransformPivotX(int viewId, float transformPivotX)

Set X location of the pivot point around which the view will rotate and scale. use Float.NaN to clear the pivot value. Note: once an actual View has had its pivot set it cannot be cleared.

Parameters
int viewId

ID of view to adjust the transforms pivot point about X

float transformPivotX

X location of the pivot point.

setTransformPivotY

Added in 2.2.0-alpha13
public void setTransformPivotY(int viewId, float transformPivotY)

Set Y location of the pivot point around which the view will rotate and scale. use Float.NaN to clear the pivot value. Note: once an actual View has had its pivot set it cannot be cleared.

Parameters
int viewId

ID of view to adjust the transforms pivot point about Y

float transformPivotY

Y location of the pivot point.

setTranslation

Added in 2.2.0-alpha13
public void setTranslation(int viewId, float translationX, float translationY)

Adjust the post-layout translation of a view.

Parameters
int viewId

ID of view to adjust its translation in X &Y

float translationX

the translation in X

float translationY

the translation in Y

setTranslationX

Added in 2.2.0-alpha13
public void setTranslationX(int viewId, float translationX)

Adjust the post-layout X translation of a view.

Parameters
int viewId

ID of view to translate in X

float translationX

the translation in X

setTranslationY

Added in 2.2.0-alpha13
public void setTranslationY(int viewId, float translationY)

Adjust the post-layout Y translation of a view.

Parameters
int viewId

ID of view to to translate in Y

float translationY

the translation in Y

setTranslationZ

Added in 2.2.0-alpha13
public void setTranslationZ(int viewId, float translationZ)

Adjust the translation in Z of a view.

Parameters
int viewId

ID of view to adjust

float translationZ

the translationZ

setValidateOnParse

Added in 2.2.0-alpha13
public void setValidateOnParse(boolean validate)

If true perform validation checks when parsing ConstraintSets This will slow down parsing and should only be used for debugging

Parameters
boolean validate

setVerticalBias

Added in 2.2.0-alpha13
public void setVerticalBias(int viewId, float bias)

Adjust the vertical bias of the view (used with views constrained on left and right).

Parameters
int viewId

ID of view to adjust the vertical

float bias

the new bias 0.5 is in the middle

setVerticalChainStyle

Added in 2.2.0-alpha13
public void setVerticalChainStyle(int viewId, int chainStyle)

How the elements of the vertical chain will be positioned. in a chain, if the dimension behaviour is set to MATCH_CONSTRAINT

  • CHAIN_SPREAD -- the elements will be spread out
  • CHAIN_SPREAD_INSIDE -- similar, but the endpoints of the chain will not be spread out
  • CHAIN_PACKED -- the elements of the chain will be packed together. The vertical bias attribute of the child will then affect the positioning of the packed elements
Parameters
int viewId

ID of view to adjust its VerticalChainStyle

int chainStyle

the weight that we can use to distribute the horizontal space

setVerticalWeight

Added in 2.2.0-alpha13
public void setVerticalWeight(int viewId, float weight)

The child's weight that we can use to distribute the available vertical space in a chain, if the dimension behaviour is set to MATCH_CONSTRAINT

Parameters
int viewId

ID of view to adjust its VerticalWeight

float weight

the weight that we can use to distribute the vertical space

setVisibility

Added in 2.2.0-alpha13
public void setVisibility(int viewId, int visibility)

Adjust the visibility of a view.

Parameters
int viewId

ID of view to adjust the vertical

int visibility

the visibility

setVisibilityMode

Added in 2.2.0-alpha13
public void setVisibilityMode(int viewId, int visibilityMode)

ConstraintSet will not setVisibility. VISIBILITY_MODE_IGNORE or VISIBILITY_MODE_NORMAL.

Parameters
int viewId

ID of view

int visibilityMode

writeState

Added in 2.2.0-alpha13
public void writeState(Writer writer, ConstraintLayout layout, int flags)

Write the state to a Writer

Parameters
Writer writer
ConstraintLayout layout
int flags