interface Dimension

Known direct subclasses
Dimension.Coercible

A Dimension that can be assigned both min and max bounds.

Dimension.MaxCoercible

A Dimension that can be assigned a max bound.

Dimension.MinCoercible

A Dimension that can be assigned a min bound.


Represents a dimension that can be assigned to the width or height of a childConstrainedLayoutReference.

Summary

Nested types

A Dimension that can be assigned both min and max bounds.

A Dimension that can be assigned a max bound.

A Dimension that can be assigned a min bound.

Public companion functions

Dimension
percent(percent: Float)

A Dimension that is a percent of the parent in the corresponding direction.

Dimension.MinCoercible

Links should be specified from both sides corresponding to this dimension, in order for this to work.

Dimension
ratio(ratio: String)

Sets the dimensions to be defined as a ratio of the width and height.

Dimension
value(dp: Dp)

Creates a Dimension representing a fixed dp size.

Public companion properties

Dimension.Coercible

Links should be specified from both sides corresponding to this dimension, in order for this to work.

Dimension

A fixed Dimension that matches the dimensions of the root ConstraintLayout.

Dimension.Coercible

Links should be specified from both sides corresponding to this dimension, in order for this to work.

Dimension

A fixed Dimension with wrap content behavior.

Public companion functions

percent

Added in 1.1.0
fun percent(percent: Float): Dimension

A Dimension that is a percent of the parent in the corresponding direction.

Where 1f is 100% and 0f is 0%.

preferredValue

fun preferredValue(dp: Dp): Dimension.MinCoercible

Links should be specified from both sides corresponding to this dimension, in order for this to work.

Creates a Dimension such that if the constraints allow it, will have the size given by dp, otherwise will take the size remaining within the constraints.

This is effectively a shorthand for fillToConstraints with a max value.

To make the value fixed (respected regardless the ConstraintSet), value should be used instead.

ratio

Added in 1.1.0
fun ratio(ratio: String): Dimension

Sets the dimensions to be defined as a ratio of the width and height. The assigned dimension will be considered to also be fillToConstraints.

The string to define a ratio is defined by the format: 'W:H'. Where H is the height as a proportion of W (the width).

Eg: width = Dimension.ratio('1:2') sets the width to be half as large as the height.

Note that only one dimension should be defined as a ratio.

value

fun value(dp: Dp): Dimension

Creates a Dimension representing a fixed dp size. The size will not change according to the constraints in the ConstraintSet.

Public companion properties

fillToConstraints

Added in 1.1.0
val fillToConstraintsDimension.Coercible

Links should be specified from both sides corresponding to this dimension, in order for this to work.

A Dimension that spreads to match constraints.

matchParent

Added in 1.1.0
val matchParentDimension

A fixed Dimension that matches the dimensions of the root ConstraintLayout. The size will not change accoring to the constraints in the ConstraintSet.

preferredWrapContent

Added in 1.1.0
val preferredWrapContentDimension.Coercible

Links should be specified from both sides corresponding to this dimension, in order for this to work.

A Dimension with suggested wrap content behavior. The wrap content size will be respected unless the constraints in the ConstraintSet do not allow it. To make the value fixed (respected regardless the ConstraintSet), wrapContent should be used instead.

wrapContent

Added in 1.1.0
val wrapContentDimension

A fixed Dimension with wrap content behavior. The size will not change according to the constraints in the ConstraintSet.