Stay organized with collections Save and categorize content based on your preferences.

Dimension

interface Dimension
androidx.constraintlayout.compose.Dimension

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

Summary

Nested classes
abstract

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

abstract

A Dimension that can be assigned a max bound.

abstract

A Dimension that can be assigned a min bound.

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.

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.

Companion functions

percent

fun percent(percent: Float): Dimension

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

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

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.

Companion properties

fillToConstraints

val fillToConstraints: Dimension.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

val matchParent: Dimension

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

preferredWrapContent

val preferredWrapContent: Dimension.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

val wrapContent: Dimension

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