Constraints
@Immutable data class Constraints
kotlin.Any | |
↳ | androidx.ui.core.Constraints |
Immutable constraints used for measuring child Layouts. A parent Layout can measure their children using the measure method on the corresponding Measurables, method which takes the Constraints the child has to follow. A measured child is then responsible to choose for themselves and return a size which satisfies the received set of Constraints:
- minWidth <= chosenWidth <= maxWidth
- minHeight <= chosenHeight <= maxHeight The parent can then access the child chosen size on the resulting Placeable. The parent is responsible of defining a valid positioning of the children according to their sizes, so the parent needs to measure the children with appropriate Constraints, such that whatever valid sizes children choose, they can be laid out in a way that also respects the parent's incoming Constraints. Note that different children can be measured with different Constraints. A set of Constraints can have infinite maxWidth and/or maxHeight. This is a trick often used by parents to ask their children for their preferred size: unbounded constraints force children whose default behavior is to fill the available space (always size to maxWidth/maxHeight) to have an opinion about their preferred size. Most commonly, when measured with unbounded Constraints, these children will fallback to size themselves to wrap their content, instead of expanding to fill the available space (this is not always true as it depends on the child layout model, but is a common behavior for core layout components).
Summary
Public constructors |
|
---|---|
<init>(minWidth: IntPx = IntPx.Zero, maxWidth: IntPx = IntPx.Infinity, minHeight: IntPx = IntPx.Zero, maxHeight: IntPx = IntPx.Infinity) Immutable constraints used for measuring child Layouts. |
Companion functions |
|
---|---|
Constraints |
tightConstraints(width: IntPx, height: IntPx) Creates constraints tight in both dimensions. |
Constraints |
tightConstraintsForHeight(height: IntPx) Creates constraints with tight height and loose width. |
Constraints |
tightConstraintsForWidth(width: IntPx) Creates constraints with tight width and loose height. |
Extension functions |
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From androidx.ui.core
|
Properties |
|
---|---|
IntPx | |
IntPx | |
IntPx | |
IntPx |
Extension properties |
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
From androidx.ui.core
|
Public constructors
<init>
Constraints(
minWidth: IntPx = IntPx.Zero,
maxWidth: IntPx = IntPx.Infinity,
minHeight: IntPx = IntPx.Zero,
maxHeight: IntPx = IntPx.Infinity)
Immutable constraints used for measuring child Layouts. A parent Layout can measure their children using the measure method on the corresponding Measurables, method which takes the Constraints the child has to follow. A measured child is then responsible to choose for themselves and return a size which satisfies the received set of Constraints:
- minWidth <= chosenWidth <= maxWidth
- minHeight <= chosenHeight <= maxHeight The parent can then access the child chosen size on the resulting Placeable. The parent is responsible of defining a valid positioning of the children according to their sizes, so the parent needs to measure the children with appropriate Constraints, such that whatever valid sizes children choose, they can be laid out in a way that also respects the parent's incoming Constraints. Note that different children can be measured with different Constraints. A set of Constraints can have infinite maxWidth and/or maxHeight. This is a trick often used by parents to ask their children for their preferred size: unbounded constraints force children whose default behavior is to fill the available space (always size to maxWidth/maxHeight) to have an opinion about their preferred size. Most commonly, when measured with unbounded Constraints, these children will fallback to size themselves to wrap their content, instead of expanding to fill the available space (this is not always true as it depends on the child layout model, but is a common behavior for core layout components).
Properties
maxHeight
val maxHeight: IntPx
maxWidth
val maxWidth: IntPx
minHeight
val minHeight: IntPx
minWidth
val minWidth: IntPx
Companion functions
tightConstraints
fun tightConstraints(
width: IntPx,
height: IntPx
): Constraints
Creates constraints tight in both dimensions.
tightConstraintsForHeight
fun tightConstraintsForHeight(height: IntPx): Constraints
Creates constraints with tight height and loose width.
tightConstraintsForWidth
fun tightConstraintsForWidth(width: IntPx): Constraints
Creates constraints with tight width and loose height.