ConstraintLayout.LayoutParams

public class 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

static final @NonNull int

The baseline of the text in a view.

static final @NonNull int

The bottom side of a view.

static final @NonNull int

Chain packed style

static final @NonNull int

Chain spread style

static final @NonNull int

Chain spread inside style

static final @NonNull int

Circle reference from a view.

static final @NonNull int

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

static final @NonNull int

Defines an id that is not set.

static final @NonNull int

The horizontal orientation.

static final @NonNull int

The left side of a view.

static final @NonNull int

Dimension will be controlled by constraints.

static final @NonNull int

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

static final @NonNull int

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

static final @NonNull int

Set matchConstraintDefault* default to the wrap content size.

static final @NonNull int

References the id of the parent.

static final @NonNull int

The right side of a view.

static final @NonNull int

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

static final @NonNull int

The top of a view.

static final @NonNull int

Defines an id that is not set.

static final @NonNull int

The vertical orientation.

static final @NonNull int
static final @NonNull int
static final @NonNull int
static final @NonNull int

Public fields

@NonNull int

The baseline margin.

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull float

The angle used for a circular constraint]

@NonNull int

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

@NonNull int

The radius used for a circular constraint

@NonNull boolean

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

@NonNull boolean

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

@NonNull String

Define a category of view to be used by helpers and motionLayout

@NonNull String

The ratio information.

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

The baseline margin to use when the target is gone.

@NonNull int

The bottom margin to use when the target is gone.

@NonNull int

The end margin to use when the target is gone.

@NonNull int

The left margin to use when the target is gone.

@NonNull int

The right margin to use when the target is gone

@NonNull int

The start margin to use when the target is gone.

@NonNull int

The top margin to use when the target is gone.

@NonNull int

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

@NonNull int

The distance of child (guideline) to the bottom or right edge of its parent.

@NonNull float

The ratio of the distance to the parent's sides

@NonNull boolean
@NonNull float

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

@NonNull int

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

@NonNull 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

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

Specify a maximum height size for the widget.

@NonNull int

Specify a maximum width size for the widget.

@NonNull int

Specify a minimum height size for the widget.

@NonNull int

Specify a minimum width size for the widget.

@NonNull float

Specify the percentage when using the match constraint percent mode.

@NonNull float

Specify the percentage when using the match constraint percent mode.

@NonNull int
@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull int

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

@NonNull float

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

@NonNull int

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

@NonNull 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

@NonNull int

Specify how this view is taken in account during the parent's wrap computation Can be either of: WRAP_BEHAVIOR_INCLUDED the widget is taken in account for the wrap (default) WRAP_BEHAVIOR_HORIZONTAL_ONLY the widget will be included in the wrap only horizontally WRAP_BEHAVIOR_VERTICAL_ONLY the widget will be included in the wrap only vertically WRAP_BEHAVIOR_SKIPPED the widget is not part of the wrap computation

Public constructors

Create a LayoutParams base on an existing layout Params

LayoutParams(@NonNull int width, @NonNull int height)

Public methods

@NonNull ConstraintWidget
@NonNull void
@Override @TargetApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1) @NonNull void
resolveLayoutDirection(@NonNull int layoutDirection)
@NonNull void
@NonNull void

Inherited methods

From class ViewGroup.MarginLayoutParams
@NonNull int
@NonNull int
@NonNull int
@NonNull boolean
@NonNull void
setLayoutDirection(@NonNull int layoutDirection)
@NonNull void
@NonNull void
setMarginStart(@NonNull int start)
@NonNull void
setMargins(
    @NonNull int left,
    @NonNull int top,
    @NonNull int right,
    @NonNull int bottom
)

Constants

BASELINE

@NonNull
public static final @NonNull int BASELINE

The baseline of the text in a view.

BOTTOM

@NonNull
public static final @NonNull int BOTTOM

The bottom side of a view.

CHAIN_PACKED

@NonNull
public static final @NonNull int CHAIN_PACKED

Chain packed style

CHAIN_SPREAD

@NonNull
public static final @NonNull int CHAIN_SPREAD

Chain spread style

CHAIN_SPREAD_INSIDE

@NonNull
public static final @NonNull int CHAIN_SPREAD_INSIDE

Chain spread inside style

CIRCLE

@NonNull
public static final @NonNull int CIRCLE

Circle reference from a view.

END

@NonNull
public static final @NonNull 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

GONE_UNSET

@NonNull
public static final @NonNull int GONE_UNSET

Defines an id that is not set.

HORIZONTAL

@NonNull
public static final @NonNull int HORIZONTAL

The horizontal orientation.

LEFT

@NonNull
public static final @NonNull int LEFT

The left side of a view.

MATCH_CONSTRAINT

@NonNull
public static final @NonNull int MATCH_CONSTRAINT

Dimension will be controlled by constraints.

MATCH_CONSTRAINT_PERCENT

@NonNull
public static final @NonNull 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

@NonNull
public static final @NonNull int MATCH_CONSTRAINT_SPREAD

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

MATCH_CONSTRAINT_WRAP

@NonNull
public static final @NonNull int MATCH_CONSTRAINT_WRAP

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

PARENT_ID

@NonNull
public static final @NonNull int PARENT_ID

References the id of the parent.

RIGHT

@NonNull
public static final @NonNull int RIGHT

The right side of a view.

START

@NonNull
public static final @NonNull 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

TOP

@NonNull
public static final @NonNull int TOP

The top of a view.

UNSET

@NonNull
public static final @NonNull int UNSET

Defines an id that is not set.

VERTICAL

@NonNull
public static final @NonNull int VERTICAL

The vertical orientation.

WRAP_BEHAVIOR_HORIZONTAL_ONLY

@NonNull
public static final @NonNull int WRAP_BEHAVIOR_HORIZONTAL_ONLY

WRAP_BEHAVIOR_INCLUDED

@NonNull
public static final @NonNull int WRAP_BEHAVIOR_INCLUDED

WRAP_BEHAVIOR_SKIPPED

@NonNull
public static final @NonNull int WRAP_BEHAVIOR_SKIPPED

WRAP_BEHAVIOR_VERTICAL_ONLY

@NonNull
public static final @NonNull int WRAP_BEHAVIOR_VERTICAL_ONLY

Public fields

baselineMargin

@NonNull
public @NonNull int baselineMargin

The baseline margin.

baselineToBaseline

@NonNull
public @NonNull int baselineToBaseline

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

baselineToBottom

@NonNull
public @NonNull int baselineToBottom

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

baselineToTop

@NonNull
public @NonNull int baselineToTop

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

bottomToBottom

@NonNull
public @NonNull int bottomToBottom

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

bottomToTop

@NonNull
public @NonNull int bottomToTop

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

circleAngle

@NonNull
public @NonNull float circleAngle

The angle used for a circular constraint]

circleConstraint

@NonNull
public @NonNull int circleConstraint

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

circleRadius

@NonNull
public @NonNull int circleRadius

The radius used for a circular constraint

constrainedHeight

@NonNull
public @NonNull 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

@NonNull
public @NonNull 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.

constraintTag

@NonNull
public @NonNull String constraintTag

Define a category of view to be used by helpers and motionLayout

dimensionRatio

@NonNull
public @NonNull String dimensionRatio

The ratio information.

editorAbsoluteX

@NonNull
public @NonNull int editorAbsoluteX

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

editorAbsoluteY

@NonNull
public @NonNull int editorAbsoluteY

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

endToEnd

@NonNull
public @NonNull int endToEnd

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

endToStart

@NonNull
public @NonNull int endToStart

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

goneBaselineMargin

@NonNull
public @NonNull int goneBaselineMargin

The baseline margin to use when the target is gone.

goneBottomMargin

@NonNull
public @NonNull int goneBottomMargin

The bottom margin to use when the target is gone.

goneEndMargin

@NonNull
public @NonNull int goneEndMargin

The end margin to use when the target is gone.

goneLeftMargin

@NonNull
public @NonNull int goneLeftMargin

The left margin to use when the target is gone.

goneRightMargin

@NonNull
public @NonNull int goneRightMargin

The right margin to use when the target is gone

goneStartMargin

@NonNull
public @NonNull int goneStartMargin

The start margin to use when the target is gone.

goneTopMargin

@NonNull
public @NonNull int goneTopMargin

The top margin to use when the target is gone.

guideBegin

@NonNull
public @NonNull int guideBegin

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

guideEnd

@NonNull
public @NonNull int guideEnd

The distance of child (guideline) to the bottom or right edge of its parent.

guidePercent

@NonNull
public @NonNull float guidePercent

The ratio of the distance to the parent's sides

helped

@NonNull
public @NonNull boolean helped

horizontalBias

@NonNull
public @NonNull float horizontalBias

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

horizontalChainStyle

@NonNull
public @NonNull 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:

  • 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

horizontalWeight

@NonNull
public @NonNull 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

@NonNull
public @NonNull int leftToLeft

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

leftToRight

@NonNull
public @NonNull int leftToRight

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

matchConstraintDefaultHeight

@NonNull
public @NonNull int matchConstraintDefaultHeight

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

  • MATCH_CONSTRAINT_SPREAD -- the default. The dimension will expand up to the constraints, minus margins
  • MATCH_CONSTRAINT_WRAP -- 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.
  • MATCH_CONSTRAINT_PERCENT -- The dimension will be a percent of another widget (by default, the parent)

matchConstraintDefaultWidth

@NonNull
public @NonNull int matchConstraintDefaultWidth

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

  • MATCH_CONSTRAINT_SPREAD -- the default. The dimension will expand up to the constraints, minus margins
  • MATCH_CONSTRAINT_WRAP -- 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.
  • MATCH_CONSTRAINT_PERCENT -- The dimension will be a percent of another widget (by default, the parent)

matchConstraintMaxHeight

@NonNull
public @NonNull 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 a vertical chain.

matchConstraintMaxWidth

@NonNull
public @NonNull 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 a horizontal chain.

matchConstraintMinHeight

@NonNull
public @NonNull 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 a vertical chain.

matchConstraintMinWidth

@NonNull
public @NonNull 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 a horizontal chain.

matchConstraintPercentHeight

@NonNull
public @NonNull float matchConstraintPercentHeight

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

matchConstraintPercentWidth

@NonNull
public @NonNull float matchConstraintPercentWidth

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

orientation

@NonNull
public @NonNull int orientation

rightToLeft

@NonNull
public @NonNull int rightToLeft

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

rightToRight

@NonNull
public @NonNull int rightToRight

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

startToEnd

@NonNull
public @NonNull int startToEnd

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

startToStart

@NonNull
public @NonNull int startToStart

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

topToBottom

@NonNull
public @NonNull int topToBottom

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

topToTop

@NonNull
public @NonNull int topToTop

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

verticalBias

@NonNull
public @NonNull float verticalBias

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

verticalChainStyle

@NonNull
public @NonNull 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:

  • 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

verticalWeight

@NonNull
public @NonNull 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

wrapBehaviorInParent

@NonNull
public @NonNull int wrapBehaviorInParent

Specify how this view is taken in account during the parent's wrap computation Can be either of: WRAP_BEHAVIOR_INCLUDED the widget is taken in account for the wrap (default) WRAP_BEHAVIOR_HORIZONTAL_ONLY the widget will be included in the wrap only horizontally WRAP_BEHAVIOR_VERTICAL_ONLY the widget will be included in the wrap only vertically WRAP_BEHAVIOR_SKIPPED the widget is not part of the wrap computation

Public constructors

LayoutParams

public LayoutParams(@NonNull ConstraintLayout.LayoutParams source)

Create a LayoutParams base on an existing layout Params

Parameters
@NonNull ConstraintLayout.LayoutParams source

the Layout Params to be copied

LayoutParams

public LayoutParams(@NonNull ViewGroup.LayoutParams source)

LayoutParams

public LayoutParams(@NonNull Context c, @NonNull AttributeSet attrs)

LayoutParams

public LayoutParams(@NonNull int width, @NonNull int height)

Public methods

getConstraintWidget

@NonNull
public ConstraintWidget getConstraintWidget()

reset

@NonNull
public void reset()

resolveLayoutDirection

@Override
@TargetApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
@NonNull
public @Override @TargetApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1) void resolveLayoutDirection(@NonNull int layoutDirection)

setWidgetDebugName

@NonNull
public void setWidgetDebugName(@NonNull String text)
Parameters
@NonNull String text

validate

@NonNull
public void validate()