lightbulb_outline Please take our October 2018 developer survey. Start survey

ConstraintLayout.LayoutParams

public static class ConstraintLayout.LayoutParams
extends ViewGroup.MarginLayoutParams

java.lang.Object
   ↳ android.view.ViewGroup.LayoutParams
     ↳ android.view.ViewGroup.MarginLayoutParams
       ↳ android.support.constraint.ConstraintLayout.LayoutParams


This class contains the different attributes specifying how a view want to be laid out inside a ConstraintLayout. For building up constraints at run time, using ConstraintSet is recommended.

Summary

Constants

int BASELINE

The baseline of the text in a view.

int BOTTOM

The bottom side of a view.

int END

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

int LEFT

The left side of a view.

int MATCH_CONSTRAINT

Dimension will be controlled by constraints.

int PARENT_ID

References the id of the parent.

int RIGHT

The right side of a view.

int START

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

int TOP

The top of a view.

int UNSET

Defines an id that is not set.

Inherited constants

Fields

public static final int CHAIN_PACKED

Chain packed style

public static final int CHAIN_SPREAD

Chain spread style

public static final int CHAIN_SPREAD_INSIDE

Chain spread inside style

public static final int HORIZONTAL

The horizontal orientation.

public static final int MATCH_CONSTRAINT_PERCENT

Set matchConstraintDefault* percent to be based on a percent of another dimension (by default, the parent) Use to set the matchConstraintDefaultWidth and matchConstraintDefaultHeight

public static final int MATCH_CONSTRAINT_SPREAD

Set matchConstraintDefault* spread as much as possible within its constraints.

public static final int MATCH_CONSTRAINT_WRAP

Set matchConstraintDefault* default to the wrap content size.

public static final int VERTICAL

The vertical orientation.

public int baselineToBaseline

Constrains the baseline of a child to the baseline of a target child (contains the target child id).

public int bottomToBottom

Constrains the bottom side of a child to the bottom side of a target child (contains the target child id).

public int bottomToTop

Constrains the bottom side of a child to the top side of a target child (contains the target child id).

public float circleAngle

The angle used for a circular constraint]

public int circleConstraint

Constrains the center of a child to the center of a target child (contains the target child id).

public int circleRadius

The radius used for a circular constraint

public boolean constrainedHeight

Specify if the vertical dimension is constrained in case both top & bottom constraints are set and the widget dimension is not a fixed dimension.

public boolean constrainedWidth

Specify if the horizontal dimension is constrained in case both left & right constraints are set and the widget dimension is not a fixed dimension.

public String dimensionRatio

The ratio information.

public int editorAbsoluteX

The design time location of the left side of the child.

public int editorAbsoluteY

The design time location of the right side of the child.

public int endToEnd

Constrains the end side of a child to the end side of a target child (contains the target child id).

public int endToStart

Constrains the end side of a child to the start side of a target child (contains the target child id).

public int goneBottomMargin

The bottom margin to use when the target is gone.

public int goneEndMargin

The end margin to use when the target is gone.

public int goneLeftMargin

The left margin to use when the target is gone.

public int goneRightMargin

The right margin to use when the target is gone

public int goneStartMargin

The start margin to use when the target is gone.

public int goneTopMargin

The top margin to use when the target is gone.

public int guideBegin

The distance of child (guideline) to the top or left edge of its parent.

public int guideEnd

The distance of child (guideline) to the top or left edge of its parent.

public float guidePercent

The ratio of the distance to the parent's sides

public boolean helped

public float horizontalBias

The ratio between two connections when the left and right (or start and end) sides are constrained.

public int horizontalChainStyle

If the child is the start of a horizontal chain, this attribute will drive how the elements of the chain will be positioned.

public float horizontalWeight

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

public int leftToLeft

Constrains the left side of a child to the left side of a target child (contains the target child id).

public int leftToRight

Constrains the left side of a child to the right side of a target child (contains the target child id).

public int matchConstraintDefaultHeight

Define how the widget vertical dimension is handled when set to MATCH_CONSTRAINT

  • -- the default.

public int matchConstraintDefaultWidth

Define how the widget horizontal dimension is handled when set to MATCH_CONSTRAINT

  • -- the default.

public int matchConstraintMaxHeight

Specify a maximum height size for the widget.

public int matchConstraintMaxWidth

Specify a maximum width size for the widget.

public int matchConstraintMinHeight

Specify a minimum height size for the widget.

public int matchConstraintMinWidth

Specify a minimum width size for the widget.

public float matchConstraintPercentHeight

Specify the percentage when using the match constraint percent mode.

public float matchConstraintPercentWidth

Specify the percentage when using the match constraint percent mode.

public int orientation

public int rightToLeft

Constrains the right side of a child to the left side of a target child (contains the target child id).

public int rightToRight

Constrains the right side of a child to the right side of a target child (contains the target child id).

public int startToEnd

Constrains the start side of a child to the end side of a target child (contains the target child id).

public int startToStart

Constrains the start side of a child to the start side of a target child (contains the target child id).

public int topToBottom

Constrains the top side of a child to the bottom side of a target child (contains the target child id).

public int topToTop

Constrains the top side of a child to the top side of a target child (contains the target child id).

public float verticalBias

The ratio between two connections when the top and bottom sides are constrained.

public int verticalChainStyle

If the child is the start of a vertical chain, this attribute will drive how the elements of the chain will be positioned.

public float verticalWeight

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

Inherited fields

Public constructors

ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams source)

Create a LayoutParams base on an existing layout Params

ConstraintLayout.LayoutParams(Context c, AttributeSet attrs)
ConstraintLayout.LayoutParams(int width, int height)
ConstraintLayout.LayoutParams(ViewGroup.LayoutParams source)

Public methods

void reset()
void resolveLayoutDirection(int layoutDirection)

void validate()

Inherited methods

Constants

BASELINE

public static final int BASELINE

The baseline of the text in a view.

Constant Value: 5 (0x00000005)

BOTTOM

public static final int BOTTOM

The bottom side of a view.

Constant Value: 4 (0x00000004)

END

public static final int END

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

Constant Value: 7 (0x00000007)

LEFT

public static final int LEFT

The left side of a view.

Constant Value: 1 (0x00000001)

MATCH_CONSTRAINT

public static final int MATCH_CONSTRAINT

Dimension will be controlled by constraints.

Constant Value: 0 (0x00000000)

PARENT_ID

public static final int PARENT_ID

References the id of the parent.

Constant Value: 0 (0x00000000)

RIGHT

public static final int RIGHT

The right side of a view.

Constant Value: 2 (0x00000002)

START

public static final int START

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

Constant Value: 6 (0x00000006)

TOP

public static final int TOP

The top of a view.

Constant Value: 3 (0x00000003)

UNSET

public static final int UNSET

Defines an id that is not set.

Constant Value: -1 (0xffffffff)

Fields

CHAIN_PACKED

public static final int CHAIN_PACKED

Chain packed style

CHAIN_SPREAD

public static final int CHAIN_SPREAD

Chain spread style

CHAIN_SPREAD_INSIDE

public static final int CHAIN_SPREAD_INSIDE

Chain spread inside style

HORIZONTAL

public static final int HORIZONTAL

The horizontal orientation.

MATCH_CONSTRAINT_PERCENT

public static final int MATCH_CONSTRAINT_PERCENT

Set matchConstraintDefault* percent to be based on a percent of another dimension (by default, the parent) Use to set the matchConstraintDefaultWidth and matchConstraintDefaultHeight

MATCH_CONSTRAINT_SPREAD

public static final int MATCH_CONSTRAINT_SPREAD

Set matchConstraintDefault* spread as much as possible within its constraints. Use to set the matchConstraintDefaultWidth and matchConstraintDefaultHeight

MATCH_CONSTRAINT_WRAP

public static final int MATCH_CONSTRAINT_WRAP

Set matchConstraintDefault* default to the wrap content size. Use to set the matchConstraintDefaultWidth and matchConstraintDefaultHeight

VERTICAL

public static final int VERTICAL

The vertical orientation.

baselineToBaseline

public int baselineToBaseline

Constrains the baseline of a child to the baseline of a target child (contains the target child id).

bottomToBottom

public int bottomToBottom

Constrains the bottom side of a child to the bottom side of a target child (contains the target child id).

bottomToTop

public int bottomToTop

Constrains the bottom side of a child to the top side of a target child (contains the target child id).

circleAngle

public float circleAngle

The angle used for a circular constraint]

circleConstraint

public int circleConstraint

Constrains the center of a child to the center of a target child (contains the target child id).

circleRadius

public int circleRadius

The radius used for a circular constraint

constrainedHeight

public boolean constrainedHeight

Specify if the vertical dimension is constrained in case both top & bottom constraints are set and the widget dimension is not a fixed dimension. By default, if a widget is set to WRAP_CONTENT, we will treat that dimension as a fixed dimension, meaning the dimension will not change regardless of constraints. Setting this attribute to true allows the dimension to change in order to respect constraints.

constrainedWidth

public boolean constrainedWidth

Specify if the horizontal dimension is constrained in case both left & right constraints are set and the widget dimension is not a fixed dimension. By default, if a widget is set to WRAP_CONTENT, we will treat that dimension as a fixed dimension, meaning the dimension will not change regardless of constraints. Setting this attribute to true allows the dimension to change in order to respect constraints.

dimensionRatio

public String dimensionRatio

The ratio information.

editorAbsoluteX

public int editorAbsoluteX

The design time location of the left side of the child. Used at design time for a horizontally unconstrained child.

editorAbsoluteY

public int editorAbsoluteY

The design time location of the right side of the child. Used at design time for a vertically unconstrained child.

endToEnd

public int endToEnd

Constrains the end side of a child to the end side of a target child (contains the target child id).

endToStart

public int endToStart

Constrains the end side of a child to the start side of a target child (contains the target child id).

goneBottomMargin

public int goneBottomMargin

The bottom margin to use when the target is gone.

goneEndMargin

public int goneEndMargin

The end margin to use when the target is gone.

goneLeftMargin

public int goneLeftMargin

The left margin to use when the target is gone.

goneRightMargin

public int goneRightMargin

The right margin to use when the target is gone

goneStartMargin

public int goneStartMargin

The start margin to use when the target is gone.

goneTopMargin

public int goneTopMargin

The top margin to use when the target is gone.

guideBegin

public int guideBegin

The distance of child (guideline) to the top or left edge of its parent.

guideEnd

public int guideEnd

The distance of child (guideline) to the top or left edge of its parent.

guidePercent

public float guidePercent

The ratio of the distance to the parent's sides

helped

public boolean helped

horizontalBias

public float horizontalBias

The ratio between two connections when the left and right (or start and end) sides are constrained.

horizontalChainStyle

public int horizontalChainStyle

If the child is the start of a horizontal chain, this attribute will drive how the elements of the chain will be positioned. The possible values are:

  • -- the elements will be spread out
  • -- similar, but the endpoints of the chain will not be spread out
  • -- 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

horizontalWeight

public float horizontalWeight

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

leftToLeft

public int leftToLeft

Constrains the left side of a child to the left side of a target child (contains the target child id).

leftToRight

public int leftToRight

Constrains the left side of a child to the right side of a target child (contains the target child id).

matchConstraintDefaultHeight

public int matchConstraintDefaultHeight

Define how the widget vertical dimension is handled when set to MATCH_CONSTRAINT

  • -- the default. The dimension will expand up to the constraints, minus margins
  • -- DEPRECATED -- use instead WRAP_CONTENT and constrainedHeight=true
    The dimension will be the same as WRAP_CONTENT, unless the size ends up too large for the constraints; in that case the dimension will expand up to the constraints, minus margins
  • This attribute may not be applied if the widget is part of a chain in that dimension.
  • -- The dimension will be a percent of another widget (by default, the parent)

matchConstraintDefaultWidth

public int matchConstraintDefaultWidth

Define how the widget horizontal dimension is handled when set to MATCH_CONSTRAINT

  • -- the default. The dimension will expand up to the constraints, minus margins
  • -- DEPRECATED -- use instead WRAP_CONTENT and constrainedWidth=true
    The dimension will be the same as WRAP_CONTENT, unless the size ends up too large for the constraints; in that case the dimension will expand up to the constraints, minus margins
  • This attribute may not be applied if the widget is part of a chain in that dimension.
  • -- The dimension will be a percent of another widget (by default, the parent)

matchConstraintMaxHeight

public int matchConstraintMaxHeight

Specify a maximum height size for the widget. It will only apply if the size of the widget is set to MATCH_CONSTRAINT. Don't apply if the widget is part of an vertical chain.

matchConstraintMaxWidth

public int matchConstraintMaxWidth

Specify a maximum width size for the widget. It will only apply if the size of the widget is set to MATCH_CONSTRAINT. Don't apply if the widget is part of an horizontal chain.

matchConstraintMinHeight

public int matchConstraintMinHeight

Specify a minimum height size for the widget. It will only apply if the size of the widget is set to MATCH_CONSTRAINT. Don't apply if the widget is part of an vertical chain.

matchConstraintMinWidth

public int matchConstraintMinWidth

Specify a minimum width size for the widget. It will only apply if the size of the widget is set to MATCH_CONSTRAINT. Don't apply if the widget is part of an horizontal chain.

matchConstraintPercentHeight

public float matchConstraintPercentHeight

Specify the percentage when using the match constraint percent mode. From 0 to 1.

matchConstraintPercentWidth

public float matchConstraintPercentWidth

Specify the percentage when using the match constraint percent mode. From 0 to 1.

orientation

public int orientation

rightToLeft

public int rightToLeft

Constrains the right side of a child to the left side of a target child (contains the target child id).

rightToRight

public int rightToRight

Constrains the right side of a child to the right side of a target child (contains the target child id).

startToEnd

public int startToEnd

Constrains the start side of a child to the end side of a target child (contains the target child id).

startToStart

public int startToStart

Constrains the start side of a child to the start side of a target child (contains the target child id).

topToBottom

public int topToBottom

Constrains the top side of a child to the bottom side of a target child (contains the target child id).

topToTop

public int topToTop

Constrains the top side of a child to the top side of a target child (contains the target child id).

verticalBias

public float verticalBias

The ratio between two connections when the top and bottom sides are constrained.

verticalChainStyle

public int verticalChainStyle

If the child is the start of a vertical chain, this attribute will drive how the elements of the chain will be positioned. The possible values are:

  • -- the elements will be spread out
  • -- similar, but the endpoints of the chain will not be spread out
  • -- 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

verticalWeight

public float verticalWeight

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

Public constructors

ConstraintLayout.LayoutParams

public ConstraintLayout.LayoutParams (ConstraintLayout.LayoutParams source)

Create a LayoutParams base on an existing layout Params

Parameters
source ConstraintLayout.LayoutParams: the Layout Params to be copied

ConstraintLayout.LayoutParams

public ConstraintLayout.LayoutParams (Context c, 
                AttributeSet attrs)

Parameters
c Context

attrs AttributeSet

ConstraintLayout.LayoutParams

public ConstraintLayout.LayoutParams (int width, 
                int height)

Parameters
width int

height int

ConstraintLayout.LayoutParams

public ConstraintLayout.LayoutParams (ViewGroup.LayoutParams source)

Parameters
source ViewGroup.LayoutParams

Public methods

reset

public void reset ()

resolveLayoutDirection

public void resolveLayoutDirection (int layoutDirection)

Parameters
layoutDirection int

validate

public void validate ()