ConstraintLayout.LayoutParams

class ConstraintLayout.LayoutParams : ViewGroup.MarginLayoutParams


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

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 = 8

Circle reference from a view.

const Int
END = 7

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

const Int
GONE_UNSET = -2147483648

Defines an id that is not set.

const Int

The horizontal orientation.

const Int
LEFT = 1

The left side of a view.

const Int

Dimension will be controlled by constraints.

const Int

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

const Int

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

const Int

Set matchConstraintDefault* default to the wrap content size.

const Int

References the id of the parent.

const Int
RIGHT = 2

The right side of a view.

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

Defines an id that is not set.

const Int

The vertical orientation.

const Int
const Int
const Int
const Int

Public constructors

Create a LayoutParams base on an existing layout Params

LayoutParams(width: Int, height: Int)

Public functions

String!

Tag that can be used to identify a view as being a member of a group.

ConstraintWidget!
Unit

Reset the ConstraintWidget

Unit
@TargetApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
resolveLayoutDirection(layoutDirection: Int)
Unit
Unit

validate the layout

Public properties

Int

The baseline margin.

Int

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

Int

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

Int

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

Int

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

Int

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

Float

The angle used for a circular constraint]

Int

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

Int

The radius used for a circular constraint

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.

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.

String!

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

String!

The ratio information.

Int

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

Int

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

Int

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

Int

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

Int

The baseline margin to use when the target is gone.

Int

The bottom margin to use when the target is gone.

Int

The end margin to use when the target is gone.

Int

The left margin to use when the target is gone.

Int

The right margin to use when the target is gone

Int

The start margin to use when the target is gone.

Int

The top margin to use when the target is gone.

Int

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

Int

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

Float

The ratio of the distance to the parent's sides

Boolean

The ratio of the distance to the parent's sides

Boolean
Float

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

Int

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

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

Int

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

Int

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

Int

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

Int

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

Int

Specify a maximum height size for the widget.

Int

Specify a maximum width size for the widget.

Int

Specify a minimum height size for the widget.

Int

Specify a minimum width size for the widget.

Float

Specify the percentage when using the match constraint percent mode.

Float

Specify the percentage when using the match constraint percent mode.

Int
Int

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

Int

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

Int

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

Int

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

Int

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

Int

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

Float

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

Int

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

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

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

Inherited Constants

From android.view.ViewGroup.LayoutParams
const Int

This property is deprecated.

const Int
const Int

Constants

BASELINE

Added in 2.2.0-alpha13
const val BASELINE = 5: Int

The baseline of the text in a view.

BOTTOM

Added in 2.2.0-alpha13
const val BOTTOM = 4: Int

The bottom side of a view.

CHAIN_PACKED

Added in 2.2.0-alpha13
const val CHAIN_PACKED = 2: Int

Chain packed style

CHAIN_SPREAD

Added in 2.2.0-alpha13
const val CHAIN_SPREAD = 0: Int

Chain spread style

CHAIN_SPREAD_INSIDE

Added in 2.2.0-alpha13
const val CHAIN_SPREAD_INSIDE = 1: Int

Chain spread inside style

CIRCLE

Added in 2.2.0-alpha13
const val CIRCLE = 8: Int

Circle reference from a view.

END

Added in 2.2.0-alpha13
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_UNSET

Added in 2.2.0-alpha13
const val GONE_UNSET = -2147483648: Int

Defines an id that is not set.

HORIZONTAL

Added in 2.2.0-alpha13
const val HORIZONTAL = 0: Int

The horizontal orientation.

LEFT

Added in 2.2.0-alpha13
const val LEFT = 1: Int

The left side of a view.

MATCH_CONSTRAINT

Added in 2.2.0-alpha13
const val MATCH_CONSTRAINT = 0: Int

Dimension will be controlled by constraints.

MATCH_CONSTRAINT_PERCENT

Added in 2.2.0-alpha13
const val MATCH_CONSTRAINT_PERCENT = 2: Int

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

Added in 2.2.0-alpha13
const val MATCH_CONSTRAINT_SPREAD = 0: Int

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

MATCH_CONSTRAINT_WRAP

Added in 2.2.0-alpha13
const val MATCH_CONSTRAINT_WRAP = 1: Int

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

PARENT_ID

Added in 2.2.0-alpha13
const val PARENT_ID = 0: Int

References the id of the parent.

RIGHT

Added in 2.2.0-alpha13
const val RIGHT = 2: Int

The right side of a view.

START

Added in 2.2.0-alpha13
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-alpha13
const val TOP = 3: Int

The top of a view.

UNSET

Added in 2.2.0-alpha13
const val UNSET = -1: Int

Defines an id that is not set.

VERTICAL

Added in 2.2.0-alpha13
const val VERTICAL = 1: Int

The vertical orientation.

WRAP_BEHAVIOR_HORIZONTAL_ONLY

Added in 2.2.0-alpha13
const val WRAP_BEHAVIOR_HORIZONTAL_ONLY = 1: Int

WRAP_BEHAVIOR_INCLUDED

Added in 2.2.0-alpha13
const val WRAP_BEHAVIOR_INCLUDED = 0: Int

WRAP_BEHAVIOR_SKIPPED

Added in 2.2.0-alpha13
const val WRAP_BEHAVIOR_SKIPPED = 3: Int

WRAP_BEHAVIOR_VERTICAL_ONLY

Added in 2.2.0-alpha13
const val WRAP_BEHAVIOR_VERTICAL_ONLY = 2: Int

Public constructors

LayoutParams

Added in 2.2.0-alpha13
LayoutParams(params: ViewGroup.LayoutParams!)

Create a LayoutParams base on an existing layout Params

Parameters
params: ViewGroup.LayoutParams!

the Layout Params to be copied

LayoutParams

Added in 2.2.0-alpha13
LayoutParams(c: Context!, attrs: AttributeSet!)

LayoutParams

Added in 2.2.0-alpha13
LayoutParams(width: Int, height: Int)

Public functions

getConstraintTag

Added in 2.2.0-alpha13
fun getConstraintTag(): String!

Tag that can be used to identify a view as being a member of a group. Which can be used for Helpers or in MotionLayout

Returns
String!

tag string or null if not defined

getConstraintWidget

Added in 2.2.0-alpha13
fun getConstraintWidget(): ConstraintWidget!

reset

Added in 2.2.0-alpha13
fun reset(): Unit

Reset the ConstraintWidget

resolveLayoutDirection

@TargetApi(value = Build.VERSION_CODES.JELLY_BEAN_MR1)
fun resolveLayoutDirection(layoutDirection: Int): Unit

setWidgetDebugName

Added in 2.2.0-alpha13
fun setWidgetDebugName(text: String!): Unit
Parameters
text: String!

validate

Added in 2.2.0-alpha13
fun validate(): Unit

validate the layout

Public properties

baselineMargin

Added in 2.2.0-alpha13
val baselineMarginInt

The baseline margin.

baselineToBaseline

Added in 2.2.0-alpha13
val baselineToBaselineInt

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

baselineToBottom

Added in 2.2.0-alpha13
val baselineToBottomInt

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

baselineToTop

Added in 2.2.0-alpha13
val baselineToTopInt

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

bottomToBottom

Added in 2.2.0-alpha13
val bottomToBottomInt

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

bottomToTop

Added in 2.2.0-alpha13
val bottomToTopInt

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

circleAngle

Added in 2.2.0-alpha13
val circleAngleFloat

The angle used for a circular constraint]

circleConstraint

Added in 2.2.0-alpha13
val circleConstraintInt

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

circleRadius

Added in 2.2.0-alpha13
val circleRadiusInt

The radius used for a circular constraint

constrainedHeight

Added in 2.2.0-alpha13
val constrainedHeightBoolean

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

Added in 2.2.0-alpha13
val constrainedWidthBoolean

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

Added in 2.2.0-alpha13
val constraintTagString!

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

dimensionRatio

Added in 2.2.0-alpha13
val dimensionRatioString!

The ratio information.

editorAbsoluteX

Added in 2.2.0-alpha13
val editorAbsoluteXInt

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

editorAbsoluteY

Added in 2.2.0-alpha13
val editorAbsoluteYInt

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

endToEnd

Added in 2.2.0-alpha13
val endToEndInt

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

endToStart

Added in 2.2.0-alpha13
val endToStartInt

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

goneBaselineMargin

Added in 2.2.0-alpha13
val goneBaselineMarginInt

The baseline margin to use when the target is gone.

goneBottomMargin

Added in 2.2.0-alpha13
val goneBottomMarginInt

The bottom margin to use when the target is gone.

goneEndMargin

Added in 2.2.0-alpha13
val goneEndMarginInt

The end margin to use when the target is gone.

goneLeftMargin

Added in 2.2.0-alpha13
val goneLeftMarginInt

The left margin to use when the target is gone.

goneRightMargin

Added in 2.2.0-alpha13
val goneRightMarginInt

The right margin to use when the target is gone

goneStartMargin

Added in 2.2.0-alpha13
val goneStartMarginInt

The start margin to use when the target is gone.

goneTopMargin

Added in 2.2.0-alpha13
val goneTopMarginInt

The top margin to use when the target is gone.

guideBegin

Added in 2.2.0-alpha13
val guideBeginInt

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

guideEnd

Added in 2.2.0-alpha13
val guideEndInt

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

guidePercent

Added in 2.2.0-alpha13
val guidePercentFloat

The ratio of the distance to the parent's sides

guidelineUseRtl

Added in 2.2.0-alpha13
val guidelineUseRtlBoolean

The ratio of the distance to the parent's sides

helped

Added in 2.2.0-alpha13
val helpedBoolean

horizontalBias

Added in 2.2.0-alpha13
val horizontalBiasFloat

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

horizontalChainStyle

Added in 2.2.0-alpha13
val horizontalChainStyleInt

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

Added in 2.2.0-alpha13
val horizontalWeightFloat

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

Added in 2.2.0-alpha13
val leftToLeftInt

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

leftToRight

Added in 2.2.0-alpha13
val leftToRightInt

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

matchConstraintDefaultHeight

Added in 2.2.0-alpha13
val matchConstraintDefaultHeightInt

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

Added in 2.2.0-alpha13
val matchConstraintDefaultWidthInt

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

Added in 2.2.0-alpha13
val matchConstraintMaxHeightInt

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

Added in 2.2.0-alpha13
val matchConstraintMaxWidthInt

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

Added in 2.2.0-alpha13
val matchConstraintMinHeightInt

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

Added in 2.2.0-alpha13
val matchConstraintMinWidthInt

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

Added in 2.2.0-alpha13
val matchConstraintPercentHeightFloat

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

matchConstraintPercentWidth

Added in 2.2.0-alpha13
val matchConstraintPercentWidthFloat

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

orientation

Added in 2.2.0-alpha13
val orientationInt

rightToLeft

Added in 2.2.0-alpha13
val rightToLeftInt

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

rightToRight

Added in 2.2.0-alpha13
val rightToRightInt

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

startToEnd

Added in 2.2.0-alpha13
val startToEndInt

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

startToStart

Added in 2.2.0-alpha13
val startToStartInt

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

topToBottom

Added in 2.2.0-alpha13
val topToBottomInt

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

topToTop

Added in 2.2.0-alpha13
val topToTopInt

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

verticalBias

Added in 2.2.0-alpha13
val verticalBiasFloat

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

verticalChainStyle

Added in 2.2.0-alpha13
val verticalChainStyleInt

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

Added in 2.2.0-alpha13
val verticalWeightFloat

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

Added in 2.2.0-alpha13
val wrapBehaviorInParentInt

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