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

Constants

const Int

The baseline of the text in a view.

const Int
BOTTOM = 4

The bottom side of a view.

const Int

Chain packed style

const Int

Chain spread style

const Int

Chain spread inside style

const Int

Circle reference from a view.

const Int
END = 7

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

const Int
GONE = 8

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

const Int

The horizontal orientation.

const Int

Used to create a horizontal create guidelines.

const Int

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

const Int
LEFT = 1

The left side of a view.

const Int

Dimension will be controlled by constraints

const Int
const Int

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

const Int

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

const Int

References the id of the parent.

const Int
RIGHT = 2

The right side of a view.

const Int
const Int
const Int
const Int
const Int
const Int
START = 6

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

const Int
TOP = 3

The top of a view.

const Int
UNSET = -1

Used to indicate a parameter is cleared or not set

const Int

The vertical orientation.

const Int

Used to create a vertical create guidelines. see create

const Int
const Int
const Int

This view is visible.

const Int

Dimension will set by the view's content

Public constructors

Public functions

Unit
addColorAttributes(attributeName: Array<String!>!)

Add attribute of type Color

Unit
addFloatAttributes(attributeName: Array<String!>!)

Add attribute of type float

Unit
addIntAttributes(attributeName: Array<String!>!)

Add attribute of type Int

Unit
addStringAttributes(attributeName: Array<String!>!)

Add attribute of type string

Unit
addToHorizontalChain(viewId: Int, leftId: Int, rightId: Int)

Adds a view to a horizontal chain.

Unit
addToHorizontalChainRTL(viewId: Int, leftId: Int, rightId: Int)

Adds a view to a horizontal chain.

Unit
addToVerticalChain(viewId: Int, topId: Int, bottomId: Int)

Adds a view to a vertical chain.

Unit

Apply custom attributes alone

Unit

Get the delta form the ConstraintSet and aplly to this

Unit
applyTo(constraintLayout: ConstraintLayout!)

Apply the constraints to a ConstraintLayout.

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

Apply Layout to Helper widget

Unit

Fill in a ConstraintLayout LayoutParam based on the id.

Unit

Apply the constraints to a ConstraintLayout.

java-static ConstraintSet.Constraint!
buildDelta(context: Context!, parser: XmlPullParser!)

Used to read a ConstraintDelta

Unit
center(
    centerID: Int,
    firstID: Int,
    firstSide: Int,
    firstMargin: Int,
    secondId: Int,
    secondSide: Int,
    secondMargin: Int,
    bias: Float
)

Center widget between the other two widgets.

Unit
centerHorizontally(viewId: Int, toView: Int)

Centers the view horizontally relative to toView's position.

Unit
centerHorizontally(
    centerID: Int,
    leftId: Int,
    leftSide: Int,
    leftMargin: Int,
    rightId: Int,
    rightSide: Int,
    rightMargin: Int,
    bias: Float
)

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

Unit
centerHorizontallyRtl(viewId: Int, toView: Int)

Centers the view horizontally relative to toView's position.

Unit
centerHorizontallyRtl(
    centerID: Int,
    startId: Int,
    startSide: Int,
    startMargin: Int,
    endId: Int,
    endSide: Int,
    endMargin: Int,
    bias: Float
)

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

Unit
centerVertically(viewId: Int, toView: Int)

Centers the view vertically relative to toView's position.

Unit
centerVertically(
    centerID: Int,
    topId: Int,
    topSide: Int,
    topMargin: Int,
    bottomId: Int,
    bottomSide: Int,
    bottomMargin: Int,
    bias: Float
)

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

Unit
clear(viewId: Int)

Remove all constraints from this view.

Unit
clear(viewId: Int, anchor: Int)

Remove a constraint from this view.

Unit
clone(constraintLayout: ConstraintLayout!)

Copy the layout parameters of a ConstraintLayout.

Unit
clone(constraints: Constraints!)

Copy the layout parameters of a ConstraintLayout.

Unit

Copy the constraints from a layout.

Unit
clone(context: Context!, constraintLayoutId: Int)

Copy the constraints from a layout.

Unit
connect(startID: Int, startSide: Int, endID: Int, endSide: Int)

Create a constraint between two widgets.

Unit
connect(startID: Int, startSide: Int, endID: Int, endSide: Int, margin: Int)

Create a constraint between two widgets.

Unit
constrainCircle(viewId: Int, id: Int, radius: Int, angle: Float)

Constrain the view on a circle constraint

Unit
constrainDefaultHeight(viewId: Int, height: Int)

Sets how the height is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD.

Unit
constrainDefaultWidth(viewId: Int, width: Int)

Sets how the width is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD.

Unit
constrainHeight(viewId: Int, height: Int)

Sets the height of the view.

Unit
constrainMaxHeight(viewId: Int, height: Int)

Sets the maximum height of the view.

Unit
constrainMaxWidth(viewId: Int, width: Int)

Sets the maximum width of the view.

Unit
constrainMinHeight(viewId: Int, height: Int)

Sets the height of the view.

Unit
constrainMinWidth(viewId: Int, width: Int)

Sets the width of the view.

Unit
constrainPercentHeight(viewId: Int, percent: Float)

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

Unit
constrainPercentWidth(viewId: Int, percent: Float)

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

Unit
constrainWidth(viewId: Int, width: Int)

Sets the width of the view.

Unit
constrainedHeight(viewId: Int, constrained: Boolean)

Sets how the height is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD.

Unit
constrainedWidth(viewId: Int, constrained: Boolean)

Sets how the width is calculated ether MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD.

Unit
create(guidelineID: Int, orientation: Int)

Creates a ConstraintLayout virtual object.

Unit
createBarrier(id: Int, direction: Int, margin: Int, referenced: IntArray!)

Creates a ConstraintLayout Barrier object.

Unit
createHorizontalChain(
    leftId: Int,
    leftSide: Int,
    rightId: Int,
    rightSide: Int,
    chainIds: IntArray!,
    weights: FloatArray!,
    style: Int
)

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

Unit
createHorizontalChainRtl(
    startId: Int,
    startSide: Int,
    endId: Int,
    endSide: Int,
    chainIds: IntArray!,
    weights: FloatArray!,
    style: Int
)

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

Unit
createVerticalChain(
    topId: Int,
    topSide: Int,
    bottomId: Int,
    bottomSide: Int,
    chainIds: IntArray!,
    weights: FloatArray!,
    style: Int
)

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

Unit
dump(scene: MotionScene!, ids: IntArray!)

Dump the contents

Boolean

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

ConstraintSet.Constraint!
HashMap<String!, ConstraintAttribute!>!
Int
getHeight(viewId: Int)

Get the height set in the view

IntArray<Int>!
ConstraintSet.Constraint!
IntArray<Int>!

get the reference id's of a helper.

Array<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(viewId: Int)

Get the visibility flag set in this view

Int

ConstraintSet will not setVisibility.

Int
getWidth(viewId: Int)

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

Unit
load(context: Context!, parser: XmlPullParser!)

Load a constraint set from a constraintSet.xml file

Unit
load(context: Context!, resourceId: Int)

Load a constraint set from a constraintSet.xml file.

Boolean

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

Unit

Parse color

Unit

Parse floats

Unit

Parse int

Unit

Parse string

Unit
readFallback(constraintLayout: ConstraintLayout!)

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

Unit

This will copy Constraints from the ConstraintSet

Unit
removeAttribute(attributeName: String!)

Remove the attribute

Unit

Removes a view from a horizontal chain.

Unit

Removes a view from a vertical chain.

Unit
setAlpha(viewId: Int, alpha: Float)

Adjust the alpha of a view.

Unit
setApplyElevation(viewId: Int, apply: Boolean)

set if elevation will be applied to the view.

Unit
setBarrierType(id: Int, type: Int)

SEt tye type of barier

Unit
setColorValue(viewId: Int, attributeName: String!, value: Int)

Set the value of an attribute of type color

Unit
setDimensionRatio(viewId: Int, ratio: String!)

Constrains the views aspect ratio.

Unit
setEditorAbsoluteX(viewId: Int, position: Int)
Unit
setEditorAbsoluteY(viewId: Int, position: Int)
Unit
setElevation(viewId: Int, elevation: Float)

Adjust the elevation of a view.

Unit
setFloatValue(viewId: Int, attributeName: String!, value: Float)

Set the value of an attribute of type float

Unit
setForceId(forceId: Boolean)

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

Unit
setGoneMargin(viewId: Int, anchor: Int, value: Int)

Sets the gone margin.

Unit
setGuidelineBegin(guidelineID: Int, margin: Int)

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

Unit
setGuidelineEnd(guidelineID: Int, margin: Int)

Set a guideline's distance to end.

Unit
setGuidelinePercent(guidelineID: Int, ratio: Float)

Set a Guideline's percent.

Unit
setHorizontalBias(viewId: Int, bias: Float)

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

Unit
setHorizontalChainStyle(viewId: Int, chainStyle: Int)

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

Unit
setHorizontalWeight(viewId: Int, weight: Float)

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

Unit
setIntValue(viewId: Int, attributeName: String!, value: Int)

Set the value of an attribute of type int

Unit
setLayoutWrapBehavior(viewId: Int, behavior: Int)

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

Unit
setMargin(viewId: Int, anchor: Int, value: Int)

Sets the margin.

Unit
setReferencedIds(id: Int, referenced: IntArray!)

sets the reference id's of a barrier.

Unit
setRotation(viewId: Int, rotation: Float)

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

Unit
setRotationX(viewId: Int, rotationX: Float)

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

Unit
setRotationY(viewId: Int, rotationY: Float)

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

Unit
setScaleX(viewId: Int, scaleX: Float)

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

Unit
setScaleY(viewId: Int, scaleY: Float)

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

Unit

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

Unit

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

Unit
setStringValue(viewId: Int, attributeName: String!, value: String!)

Set the value of an attribute of type string

Unit
setTransformPivot(
    viewId: Int,
    transformPivotX: Float,
    transformPivotY: Float
)

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

Unit
setTransformPivotX(viewId: Int, transformPivotX: Float)

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

Unit
setTransformPivotY(viewId: Int, transformPivotY: Float)

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

Unit
setTranslation(viewId: Int, translationX: Float, translationY: Float)

Adjust the post-layout translation of a view.

Unit
setTranslationX(viewId: Int, translationX: Float)

Adjust the post-layout X translation of a view.

Unit
setTranslationY(viewId: Int, translationY: Float)

Adjust the post-layout Y translation of a view.

Unit
setTranslationZ(viewId: Int, translationZ: Float)

Adjust the translation in Z of a view.

Unit

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

Unit
setVerticalBias(viewId: Int, bias: Float)

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

Unit
setVerticalChainStyle(viewId: Int, chainStyle: Int)

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

Unit
setVerticalWeight(viewId: Int, weight: Float)

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

Unit
setVisibility(viewId: Int, visibility: Int)

Adjust the visibility of a view.

Unit
setVisibilityMode(viewId: Int, visibilityMode: Int)

ConstraintSet will not setVisibility.

Unit
writeState(writer: Writer!, layout: ConstraintLayout!, flags: Int)

Write the state to a Writer

Constants

BASELINE

Added in 2.2.0
const val BASELINE = 5: Int

The baseline of the text in a view.

BOTTOM

Added in 2.2.0
const val BOTTOM = 4: Int

The bottom side of a view.

CHAIN_PACKED

Added in 2.2.0
const val CHAIN_PACKED = 2: Int

Chain packed style

CHAIN_SPREAD

Added in 2.2.0
const val CHAIN_SPREAD = 0: Int

Chain spread style

CHAIN_SPREAD_INSIDE

Added in 2.2.0
const val CHAIN_SPREAD_INSIDE = 1: Int

Chain spread inside style

CIRCLE_REFERENCE

Added in 2.2.0
const val CIRCLE_REFERENCE = 8: Int

Circle reference from a view.

END

Added in 2.2.0
const val END = 7: Int

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
const val GONE = 8: Int

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
const val HORIZONTAL = 0: Int

The horizontal orientation.

HORIZONTAL_GUIDELINE

Added in 2.2.0
const val HORIZONTAL_GUIDELINE = 0: Int

Used to create a horizontal create guidelines.

INVISIBLE

Added in 2.2.0
const val INVISIBLE = 4: Int

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
const val LEFT = 1: Int

The left side of a view.

MATCH_CONSTRAINT

Added in 2.2.0
const val MATCH_CONSTRAINT = 0: Int

Dimension will be controlled by constraints

MATCH_CONSTRAINT_PERCENT

Added in 2.2.0
const val MATCH_CONSTRAINT_PERCENT = 2: Int

MATCH_CONSTRAINT_SPREAD

Added in 2.2.0
const val MATCH_CONSTRAINT_SPREAD = 0: Int

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
const val MATCH_CONSTRAINT_WRAP = 1: Int

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

PARENT_ID

Added in 2.2.0
const val PARENT_ID = 0: Int

References the id of the parent. Used in:

RIGHT

Added in 2.2.0
const val RIGHT = 2: Int

The right side of a view.

ROTATE_LEFT_OF_PORTRATE

Added in 2.2.0
const val ROTATE_LEFT_OF_PORTRATE = 4: Int

ROTATE_NONE

Added in 2.2.0
const val ROTATE_NONE = 0: Int

ROTATE_PORTRATE_OF_LEFT

Added in 2.2.0
const val ROTATE_PORTRATE_OF_LEFT = 2: Int

ROTATE_PORTRATE_OF_RIGHT

Added in 2.2.0
const val ROTATE_PORTRATE_OF_RIGHT = 1: Int

ROTATE_RIGHT_OF_PORTRATE

Added in 2.2.0
const val ROTATE_RIGHT_OF_PORTRATE = 3: Int

START

Added in 2.2.0
const val START = 6: Int

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
const val TOP = 3: Int

The top of a view.

UNSET

Added in 2.2.0
const val UNSET = -1: Int

Used to indicate a parameter is cleared or not set

VERTICAL

Added in 2.2.0
const val VERTICAL = 1: Int

The vertical orientation.

VERTICAL_GUIDELINE

Added in 2.2.0
const val VERTICAL_GUIDELINE = 1: Int

Used to create a vertical create guidelines. see create

VISIBILITY_MODE_IGNORE

Added in 2.2.0
const val VISIBILITY_MODE_IGNORE = 1: Int

VISIBILITY_MODE_NORMAL

Added in 2.2.0
const val VISIBILITY_MODE_NORMAL = 0: Int

VISIBLE

Added in 2.2.0
const val VISIBLE = 0: Int

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

WRAP_CONTENT

Added in 2.2.0
const val WRAP_CONTENT = -2: Int

Dimension will set by the view's content

Public constructors

ConstraintSet

Added in 2.2.0
ConstraintSet()

Public functions

addColorAttributes

fun addColorAttributes(attributeName: Array<String!>!): Unit

Add attribute of type Color

Parameters
attributeName: Array<String!>!

addFloatAttributes

fun addFloatAttributes(attributeName: Array<String!>!): Unit

Add attribute of type float

Parameters
attributeName: Array<String!>!

addIntAttributes

fun addIntAttributes(attributeName: Array<String!>!): Unit

Add attribute of type Int

Parameters
attributeName: Array<String!>!

addStringAttributes

fun addStringAttributes(attributeName: Array<String!>!): Unit

Add attribute of type string

Parameters
attributeName: Array<String!>!

addToHorizontalChain

Added in 2.2.0
fun addToHorizontalChain(viewId: Int, leftId: Int, rightId: Int): Unit

Adds a view to a horizontal chain.

Parameters
viewId: Int

view to add

leftId: Int

view in chain to the left

rightId: Int

view in chain to the right

addToHorizontalChainRTL

Added in 2.2.0
fun addToHorizontalChainRTL(viewId: Int, leftId: Int, rightId: Int): Unit

Adds a view to a horizontal chain.

Parameters
viewId: Int

view to add

leftId: Int

view to the start side

rightId: Int

view to the end side

addToVerticalChain

Added in 2.2.0
fun addToVerticalChain(viewId: Int, topId: Int, bottomId: Int): Unit

Adds a view to a vertical chain.

Parameters
viewId: Int

view to add to a vertical chain

topId: Int

view above.

bottomId: Int

view below

applyCustomAttributes

Added in 2.2.0
fun applyCustomAttributes(constraintLayout: ConstraintLayout!): Unit

Apply custom attributes alone

Parameters
constraintLayout: ConstraintLayout!

applyDeltaFrom

Added in 2.2.0
fun applyDeltaFrom(cs: ConstraintSet!): Unit

Get the delta form the ConstraintSet and aplly to this

Parameters
cs: ConstraintSet!

applyTo

Added in 2.2.0
fun applyTo(constraintLayout: ConstraintLayout!): Unit

Apply the constraints to a ConstraintLayout.

Parameters
constraintLayout: ConstraintLayout!

to be modified

applyToHelper

Added in 2.2.0
fun applyToHelper(
    helper: ConstraintHelper!,
    child: ConstraintWidget!,
    layoutParams: ConstraintLayout.LayoutParams!,
    mapIdToWidget: SparseArray<ConstraintWidget!>!
): Unit

Apply Layout to Helper widget

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

applyToLayoutParams

Added in 2.2.0
fun applyToLayoutParams(id: Int, layoutParams: ConstraintLayout.LayoutParams!): Unit

Fill in a ConstraintLayout LayoutParam based on the id.

Parameters
id: Int

Id of the view

layoutParams: ConstraintLayout.LayoutParams!

LayoutParams to be filled

applyToWithoutCustom

Added in 2.2.0
fun applyToWithoutCustom(constraintLayout: ConstraintLayout!): Unit

Apply the constraints to a ConstraintLayout.

Parameters
constraintLayout: ConstraintLayout!

to be modified

buildDelta

Added in 2.2.0
java-static fun buildDelta(context: Context!, parser: XmlPullParser!): ConstraintSet.Constraint!

Used to read a ConstraintDelta

Parameters
context: Context!
parser: XmlPullParser!

center

Added in 2.2.0
fun center(
    centerID: Int,
    firstID: Int,
    firstSide: Int,
    firstMargin: Int,
    secondId: Int,
    secondSide: Int,
    secondMargin: Int,
    bias: Float
): Unit

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
centerID: Int

ID of the widget to be centered

firstID: Int

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

firstSide: Int

the side of the widget to connect to

firstMargin: Int

the connection margin

secondId: Int

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

secondSide: Int

the side of the widget to connect to

secondMargin: Int

the connection margin

bias: Float

the ratio between two connections

centerHorizontally

Added in 2.2.0
fun centerHorizontally(viewId: Int, toView: Int): Unit

Centers the view horizontally relative to toView's position.

Parameters
viewId: Int

ID of view to center Horizontally

toView: Int

ID of view to center on (or in)

centerHorizontally

Added in 2.2.0
fun centerHorizontally(
    centerID: Int,
    leftId: Int,
    leftSide: Int,
    leftMargin: Int,
    rightId: Int,
    rightSide: Int,
    rightMargin: Int,
    bias: Float
): Unit

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

Parameters
centerID: Int

ID of widget to be centered

leftId: Int

The Id of the widget on the left side

leftSide: Int

The side of the leftId widget to connect to

leftMargin: Int

The margin on the left side

rightId: Int

The Id of the widget on the right side

rightSide: Int

The side of the rightId widget to connect to

rightMargin: Int

The margin on the right side

bias: Float

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

centerHorizontallyRtl

Added in 2.2.0
fun centerHorizontallyRtl(viewId: Int, toView: Int): Unit

Centers the view horizontally relative to toView's position.

Parameters
viewId: Int

ID of view to center Horizontally

toView: Int

ID of view to center on (or in)

centerHorizontallyRtl

Added in 2.2.0
fun centerHorizontallyRtl(
    centerID: Int,
    startId: Int,
    startSide: Int,
    startMargin: Int,
    endId: Int,
    endSide: Int,
    endMargin: Int,
    bias: Float
): Unit

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

Parameters
centerID: Int

ID of widget to be centered

startId: Int

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

startSide: Int

The side of the startId widget to connect to

startMargin: Int

The margin on the start side

endId: Int

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

endSide: Int

The side of the endId widget to connect to

endMargin: Int

The margin on the end side

bias: Float

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

centerVertically

Added in 2.2.0
fun centerVertically(viewId: Int, toView: Int): Unit

Centers the view vertically relative to toView's position.

Parameters
viewId: Int

ID of view to center Horizontally

toView: Int

ID of view to center on (or in)

centerVertically

Added in 2.2.0
fun centerVertically(
    centerID: Int,
    topId: Int,
    topSide: Int,
    topMargin: Int,
    bottomId: Int,
    bottomSide: Int,
    bottomMargin: Int,
    bias: Float
): Unit

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

Parameters
centerID: Int

ID of widget to be centered

topId: Int

The Id of the widget on the top side

topSide: Int

The side of the leftId widget to connect to

topMargin: Int

The margin on the top side

bottomId: Int

The Id of the widget on the bottom side

bottomSide: Int

The side of the bottomId widget to connect to

bottomMargin: Int

The margin on the bottom side

bias: Float

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

clear

Added in 2.2.0
fun clear(viewId: Int): Unit

Remove all constraints from this view.

Parameters
viewId: Int

ID of view to remove all connections to

clear

Added in 2.2.0
fun clear(viewId: Int, anchor: Int): Unit

Remove a constraint from this view.

Parameters
viewId: Int

ID of view to center on (or in)

anchor: Int

the Anchor to remove constraint from

clone

Added in 2.2.0
fun clone(constraintLayout: ConstraintLayout!): Unit

Copy the layout parameters of a ConstraintLayout.

Parameters
constraintLayout: ConstraintLayout!

The ConstraintLayout to be copied

clone

Added in 2.2.0
fun clone(constraints: Constraints!): Unit

Copy the layout parameters of a ConstraintLayout.

Parameters
constraints: Constraints!

The ConstraintLayout to be copied

clone

Added in 2.2.0
fun clone(set: ConstraintSet!): Unit

Copy the constraints from a layout.

Parameters
set: ConstraintSet!

constraint set to copy

clone

Added in 2.2.0
fun clone(context: Context!, constraintLayoutId: Int): Unit

Copy the constraints from a layout.

Parameters
context: Context!

the context for the layout inflation

constraintLayoutId: Int

the id of the layout file

connect

Added in 2.2.0
fun connect(startID: Int, startSide: Int, endID: Int, endSide: Int): Unit

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

Parameters
startID: Int

the ID of the widget to be constrained

startSide: Int

the side of the widget to constrain

endID: Int

the id of the widget to constrain to

endSide: Int

the side of widget to constrain to

connect

Added in 2.2.0
fun connect(startID: Int, startSide: Int, endID: Int, endSide: Int, margin: Int): Unit

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

Parameters
startID: Int

the ID of the widget to be constrained

startSide: Int

the side of the widget to constrain

endID: Int

the id of the widget to constrain to

endSide: Int

the side of widget to constrain to

margin: Int

the margin to constrain (margin must be positive)

constrainCircle

Added in 2.2.0
fun constrainCircle(viewId: Int, id: Int, radius: Int, angle: Float): Unit

Constrain the view on a circle constraint

Parameters
viewId: Int

ID of the view we constrain

id: Int

ID of the view we constrain relative to

radius: Int

the radius of the circle in degrees

angle: Float

the angle

constrainDefaultHeight

Added in 2.2.0
fun constrainDefaultHeight(viewId: Int, height: Int): Unit

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

Parameters
viewId: Int

ID of view to adjust its matchConstraintDefaultHeight

height: Int

MATCH_CONSTRAINT_WRAP or MATCH_CONSTRAINT_SPREAD

constrainDefaultWidth

Added in 2.2.0
fun constrainDefaultWidth(viewId: Int, width: Int): Unit

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

Parameters
viewId: Int

ID of view to adjust its matchConstraintDefaultWidth

width: Int

SPREAD or WRAP

constrainHeight

Added in 2.2.0
fun constrainHeight(viewId: Int, height: Int): Unit

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

Parameters
viewId: Int

ID of view to adjust its height

height: Int

the height of the view

constrainMaxHeight

Added in 2.2.0
fun constrainMaxHeight(viewId: Int, height: Int): Unit

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

Parameters
viewId: Int

ID of view to adjust it height

height: Int

the maximum height of the constraint

constrainMaxWidth

Added in 2.2.0
fun constrainMaxWidth(viewId: Int, width: Int): Unit

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

Parameters
viewId: Int

ID of view to adjust its max height

width: Int

the maximum width of the view

constrainMinHeight

Added in 2.2.0
fun constrainMinHeight(viewId: Int, height: Int): Unit

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

Parameters
viewId: Int

ID of view to adjust its min height

height: Int

the minimum height of the view

constrainMinWidth

Added in 2.2.0
fun constrainMinWidth(viewId: Int, width: Int): Unit

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

Parameters
viewId: Int

ID of view to adjust its min height

width: Int

the minimum width of the view

constrainPercentHeight

Added in 2.2.0
fun constrainPercentHeight(viewId: Int, percent: Float): Unit

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

Parameters
viewId: Int
percent: Float

constrainPercentWidth

Added in 2.2.0
fun constrainPercentWidth(viewId: Int, percent: Float): Unit

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

Parameters
viewId: Int
percent: Float

constrainWidth

Added in 2.2.0
fun constrainWidth(viewId: Int, width: Int): Unit

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

Parameters
viewId: Int

ID of view to adjust its width

width: Int

the width of the view

constrainedHeight

Added in 2.2.0
fun constrainedHeight(viewId: Int, constrained: Boolean): Unit

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

Parameters
viewId: Int

ID of view to adjust its matchConstraintDefaultHeight

constrained: Boolean

if true height will be constrained

constrainedWidth

Added in 2.2.0
fun constrainedWidth(viewId: Int, constrained: Boolean): Unit

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

Parameters
viewId: Int

ID of view to adjust its matchConstraintDefaultWidth

constrained: Boolean

if true with will be constrained

create

Added in 2.2.0
fun create(guidelineID: Int, orientation: Int): Unit

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

Parameters
guidelineID: Int

ID of guideline to create

orientation: Int

the Orientation of the guideline

createBarrier

fun createBarrier(id: Int, direction: Int, margin: Int, referenced: IntArray!): Unit

Creates a ConstraintLayout Barrier object.

Parameters
id: Int
direction: Int

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

referenced: IntArray!

createHorizontalChain

Added in 2.2.0
fun createHorizontalChain(
    leftId: Int,
    leftSide: Int,
    rightId: Int,
    rightSide: Int,
    chainIds: IntArray!,
    weights: FloatArray!,
    style: Int
): Unit

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
leftId: Int

The id of the widget to connect to or PARENT_ID

leftSide: Int

the side of the start to connect to

rightId: Int

The id of the widget to connect to or PARENT_ID

rightSide: Int

the side of the right to connect to

chainIds: IntArray!

The widgets in the chain

weights: FloatArray!

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

style: Int

The type of chain

createHorizontalChainRtl

Added in 2.2.0
fun createHorizontalChainRtl(
    startId: Int,
    startSide: Int,
    endId: Int,
    endSide: Int,
    chainIds: IntArray!,
    weights: FloatArray!,
    style: Int
): Unit

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
startId: Int

The id of the widget to connect to or PARENT_ID

startSide: Int

the side of the start to connect to

endId: Int

The id of the widget to connect to or PARENT_ID

endSide: Int

the side of the end to connect to

chainIds: IntArray!

The widgets in the chain

weights: FloatArray!

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

style: Int

The type of chain

createVerticalChain

Added in 2.2.0
fun createVerticalChain(
    topId: Int,
    topSide: Int,
    bottomId: Int,
    bottomSide: Int,
    chainIds: IntArray!,
    weights: FloatArray!,
    style: Int
): Unit

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
topId: Int

The id of the widget to connect to or PARENT_ID

topSide: Int

the side of the start to connect to

bottomId: Int

The id of the widget to connect to or PARENT_ID

bottomSide: Int

the side of the right to connect to

chainIds: IntArray!

widgets to use as a chain

weights: FloatArray!

can be null

style: Int

set the style of the chain

dump

fun dump(scene: MotionScene!, ids: IntArray!): Unit

Dump the contents

Parameters
scene: MotionScene!
ids: IntArray!

getApplyElevation

Added in 2.2.0
fun getApplyElevation(viewId: Int): Boolean

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
fun getConstraint(id: Int): ConstraintSet.Constraint!

getCustomAttributeSet

Added in 2.2.0
fun getCustomAttributeSet(): HashMap<String!, ConstraintAttribute!>!

getHeight

Added in 2.2.0
fun getHeight(viewId: Int): Int

Get the height set in the view

Parameters
viewId: Int

the id of the view

Returns
Int

return the height constraint of the view

getKnownIds

Added in 2.2.0
fun getKnownIds(): IntArray<Int>!

getParameters

Added in 2.2.0
fun getParameters(mId: Int): ConstraintSet.Constraint!
Parameters
mId: Int

getReferencedIds

Added in 2.2.0
fun getReferencedIds(id: Int): IntArray<Int>!

get the reference id's of a helper.

Parameters
id: Int
Returns
IntArray<Int>!

array of id's

getStateLabels

Added in 2.2.0
fun getStateLabels(): Array<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

Returns
Array<String!>!

an array of type strings

getVisibility

Added in 2.2.0
fun getVisibility(viewId: Int): Int

Get the visibility flag set in this view

Parameters
viewId: Int

the id of the view

Returns
Int

the visibility constraint for the view

getVisibilityMode

Added in 2.2.0
fun getVisibilityMode(viewId: Int): Int

ConstraintSet will not setVisibility. VISIBILITY_MODE_IGNORE or VISIBILITY_MODE_NORMAL.

Parameters
viewId: Int

ID of view

getWidth

Added in 2.2.0
fun getWidth(viewId: Int): Int

Get the width set in the view

Parameters
viewId: Int

the id of the view

Returns
Int

return the width constraint of the view

isForceId

Added in 2.2.0
fun isForceId(): Boolean

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

isValidateOnParse

Added in 2.2.0
fun isValidateOnParse(): Boolean

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
fun load(context: Context!, parser: XmlPullParser!): Unit

Load a constraint set from a constraintSet.xml file

Parameters
context: Context!

the context for the inflation

parser: XmlPullParser!

id of xml file in res/xml/

load

Added in 2.2.0
fun load(context: Context!, resourceId: Int): Unit

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

resourceId: Int

id of xml file in res/xml/

matchesLabels

fun matchesLabels(types: Array<String!>!): Boolean

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

Parameters
types: Array<String!>!

list of types

Returns
Boolean

true if all types are in the labels

parseColorAttributes

Added in 2.2.0
fun parseColorAttributes(set: ConstraintSet.Constraint!, attributes: String!): Unit

Parse color

Parameters
set: ConstraintSet.Constraint!
attributes: String!

parseFloatAttributes

Added in 2.2.0
fun parseFloatAttributes(set: ConstraintSet.Constraint!, attributes: String!): Unit

Parse floats

Parameters
set: ConstraintSet.Constraint!
attributes: String!

parseIntAttributes

Added in 2.2.0
fun parseIntAttributes(set: ConstraintSet.Constraint!, attributes: String!): Unit

Parse int

Parameters
set: ConstraintSet.Constraint!
attributes: String!

parseStringAttributes

Added in 2.2.0
fun parseStringAttributes(set: ConstraintSet.Constraint!, attributes: String!): Unit

Parse string

Parameters
set: ConstraintSet.Constraint!
attributes: String!

readFallback

Added in 2.2.0
fun readFallback(constraintLayout: ConstraintLayout!): Unit

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

Parameters
constraintLayout: ConstraintLayout!

readFallback

Added in 2.2.0
fun readFallback(set: ConstraintSet!): Unit

This will copy Constraints from the ConstraintSet

Parameters
set: ConstraintSet!

removeAttribute

Added in 2.2.0
fun removeAttribute(attributeName: String!): Unit

Remove the attribute

Parameters
attributeName: String!

removeFromHorizontalChain

Added in 2.2.0
fun removeFromHorizontalChain(viewId: Int): Unit

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
viewId: Int

the view to be removed

removeFromVerticalChain

Added in 2.2.0
fun removeFromVerticalChain(viewId: Int): Unit

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
viewId: Int

the view to be removed

setAlpha

Added in 2.2.0
fun setAlpha(viewId: Int, alpha: Float): Unit

Adjust the alpha of a view.

Parameters
viewId: Int

ID of view to adjust the vertical

alpha: Float

the alpha

setApplyElevation

Added in 2.2.0
fun setApplyElevation(viewId: Int, apply: Boolean): Unit

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
apply: Boolean

true if this constraint set applies elevation to this view

setBarrierType

Added in 2.2.0
fun setBarrierType(id: Int, type: Int): Unit

SEt tye type of barier

Parameters
id: Int
type: Int

setColorValue

Added in 2.2.0
fun setColorValue(viewId: Int, attributeName: String!, value: Int): Unit

Set the value of an attribute of type color

Parameters
viewId: Int
attributeName: String!
value: Int

setDimensionRatio

Added in 2.2.0
fun setDimensionRatio(viewId: Int, ratio: String!): Unit

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

Parameters
viewId: Int

ID of view to constrain

ratio: String!

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

setEditorAbsoluteX

Added in 2.2.0
fun setEditorAbsoluteX(viewId: Int, position: Int): Unit

setEditorAbsoluteY

Added in 2.2.0
fun setEditorAbsoluteY(viewId: Int, position: Int): Unit

setElevation

Added in 2.2.0
fun setElevation(viewId: Int, elevation: Float): Unit

Adjust the elevation of a view.

Parameters
viewId: Int

ID of view to adjust the elevation

elevation: Float

the elevation

setFloatValue

Added in 2.2.0
fun setFloatValue(viewId: Int, attributeName: String!, value: Float): Unit

Set the value of an attribute of type float

Parameters
viewId: Int
attributeName: String!
value: Float

setForceId

Added in 2.2.0
fun setForceId(forceId: Boolean): Unit

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

Parameters
forceId: Boolean

setGoneMargin

Added in 2.2.0
fun setGoneMargin(viewId: Int, anchor: Int, value: Int): Unit

Sets the gone margin.

Parameters
viewId: Int

ID of view to adjust the margin on

anchor: Int

The side to adjust the margin on

value: Int

The new value for the margin

setGuidelineBegin

Added in 2.2.0
fun setGuidelineBegin(guidelineID: Int, margin: Int): Unit

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

Parameters
guidelineID: Int

ID of the guideline

margin: Int

the distance to the top or left edge

setGuidelineEnd

Added in 2.2.0
fun setGuidelineEnd(guidelineID: Int, margin: Int): Unit

Set a guideline's distance to end.

Parameters
guidelineID: Int

ID of the guideline

margin: Int

the margin to the right or bottom side of container

setGuidelinePercent

Added in 2.2.0
fun setGuidelinePercent(guidelineID: Int, ratio: Float): Unit

Set a Guideline's percent.

Parameters
guidelineID: Int

ID of the guideline

ratio: Float

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
fun setHorizontalBias(viewId: Int, bias: Float): Unit

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

Parameters
viewId: Int

ID of view to adjust the horizontal

bias: Float

the new bias 0.5 is in the middle

setHorizontalChainStyle

Added in 2.2.0
fun setHorizontalChainStyle(viewId: Int, chainStyle: Int): Unit

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
viewId: Int

ID of view to adjust its HorizontalChainStyle

chainStyle: Int

the weight that we can use to distribute the horizontal space

setHorizontalWeight

Added in 2.2.0
fun setHorizontalWeight(viewId: Int, weight: Float): Unit

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
viewId: Int

ID of view to adjust its HorizontalWeight

weight: Float

the weight that we can use to distribute the horizontal space

setIntValue

Added in 2.2.0
fun setIntValue(viewId: Int, attributeName: String!, value: Int): Unit

Set the value of an attribute of type int

Parameters
viewId: Int
attributeName: String!
value: Int

setLayoutWrapBehavior

Added in 2.2.0
fun setLayoutWrapBehavior(viewId: Int, behavior: Int): Unit

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

setMargin

Added in 2.2.0
fun setMargin(viewId: Int, anchor: Int, value: Int): Unit

Sets the margin.

Parameters
viewId: Int

ID of view to adjust the margin on

anchor: Int

The side to adjust the margin on

value: Int

The new value for the margin

setReferencedIds

fun setReferencedIds(id: Int, referenced: IntArray!): Unit

sets the reference id's of a barrier.

Parameters
id: Int
referenced: IntArray!

setRotation

Added in 2.2.0
fun setRotation(viewId: Int, rotation: Float): Unit

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

Parameters
viewId: Int

ID of view to adjust th Z rotation

rotation: Float

the rotation about the X axis

setRotationX

Added in 2.2.0
fun setRotationX(viewId: Int, rotationX: Float): Unit

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

Parameters
viewId: Int

ID of view to adjust th X rotation

rotationX: Float

the rotation about the X axis

setRotationY

Added in 2.2.0
fun setRotationY(viewId: Int, rotationY: Float): Unit

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

Parameters
viewId: Int

ID of view to adjust the Y rotation

rotationY: Float

the rotationY

setScaleX

Added in 2.2.0
fun setScaleX(viewId: Int, scaleX: Float): Unit

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

Parameters
viewId: Int

ID of view to adjust the scale in X

scaleX: Float

the scale in X

setScaleY

Added in 2.2.0
fun setScaleY(viewId: Int, scaleY: Float): Unit

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

Parameters
viewId: Int

ID of view to adjust the scale in Y

scaleY: Float

the scale in Y

setStateLabels

Added in 2.2.0
fun setStateLabels(types: String!): Unit

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
types: String!

a comer separated array of strings.

setStateLabelsList

fun setStateLabelsList(types: Array<String!>!): Unit

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
types: Array<String!>!

a comer separated array of strings.

setStringValue

Added in 2.2.0
fun setStringValue(viewId: Int, attributeName: String!, value: String!): Unit

Set the value of an attribute of type string

Parameters
viewId: Int
attributeName: String!
value: String!

setTransformPivot

Added in 2.2.0
fun setTransformPivot(
    viewId: Int,
    transformPivotX: Float,
    transformPivotY: Float
): Unit

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
viewId: Int

ID of view to adjust the transforms pivot point

transformPivotX: Float

X location of the pivot point.

transformPivotY: Float

Y location of the pivot point.

setTransformPivotX

Added in 2.2.0
fun setTransformPivotX(viewId: Int, transformPivotX: Float): Unit

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
viewId: Int

ID of view to adjust the transforms pivot point about X

transformPivotX: Float

X location of the pivot point.

setTransformPivotY

Added in 2.2.0
fun setTransformPivotY(viewId: Int, transformPivotY: Float): Unit

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
viewId: Int

ID of view to adjust the transforms pivot point about Y

transformPivotY: Float

Y location of the pivot point.

setTranslation

Added in 2.2.0
fun setTranslation(viewId: Int, translationX: Float, translationY: Float): Unit

Adjust the post-layout translation of a view.

Parameters
viewId: Int

ID of view to adjust its translation in X &Y

translationX: Float

the translation in X

translationY: Float

the translation in Y

setTranslationX

Added in 2.2.0
fun setTranslationX(viewId: Int, translationX: Float): Unit

Adjust the post-layout X translation of a view.

Parameters
viewId: Int

ID of view to translate in X

translationX: Float

the translation in X

setTranslationY

Added in 2.2.0
fun setTranslationY(viewId: Int, translationY: Float): Unit

Adjust the post-layout Y translation of a view.

Parameters
viewId: Int

ID of view to to translate in Y

translationY: Float

the translation in Y

setTranslationZ

Added in 2.2.0
fun setTranslationZ(viewId: Int, translationZ: Float): Unit

Adjust the translation in Z of a view.

Parameters
viewId: Int

ID of view to adjust

translationZ: Float

the translationZ

setValidateOnParse

Added in 2.2.0
fun setValidateOnParse(validate: Boolean): Unit

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

Parameters
validate: Boolean

setVerticalBias

Added in 2.2.0
fun setVerticalBias(viewId: Int, bias: Float): Unit

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

Parameters
viewId: Int

ID of view to adjust the vertical

bias: Float

the new bias 0.5 is in the middle

setVerticalChainStyle

Added in 2.2.0
fun setVerticalChainStyle(viewId: Int, chainStyle: Int): Unit

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
viewId: Int

ID of view to adjust its VerticalChainStyle

chainStyle: Int

the weight that we can use to distribute the horizontal space

setVerticalWeight

Added in 2.2.0
fun setVerticalWeight(viewId: Int, weight: Float): Unit

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
viewId: Int

ID of view to adjust its VerticalWeight

weight: Float

the weight that we can use to distribute the vertical space

setVisibility

Added in 2.2.0
fun setVisibility(viewId: Int, visibility: Int): Unit

Adjust the visibility of a view.

Parameters
viewId: Int

ID of view to adjust the vertical

visibility: Int

the visibility

setVisibilityMode

Added in 2.2.0
fun setVisibilityMode(viewId: Int, visibilityMode: Int): Unit

ConstraintSet will not setVisibility. VISIBILITY_MODE_IGNORE or VISIBILITY_MODE_NORMAL.

Parameters
viewId: Int

ID of view

visibilityMode: Int

writeState

Added in 2.2.0
fun writeState(writer: Writer!, layout: ConstraintLayout!, flags: Int): Unit

Write the state to a Writer

Parameters
writer: Writer!
layout: ConstraintLayout!
flags: Int

Public properties

derivedState

Added in 2.2.0
val derivedStateString!

mIdString

Added in 2.2.0
val mIdStringString!

mRotate

Added in 2.2.0
val mRotateInt