Compose Unstyled 2.0 is out! Check the official announcement blog ->
Function

requiredSize

Declare the size of the content to be exactly a size dp cube, disregarding the incoming VolumeConstraints.

requiredSize

Source set: Android
public fun SubspaceModifier.requiredSize(size: Dp): SubspaceModifier

Declare the size of the content to be exactly a size dp cube, disregarding the incoming VolumeConstraints. When applied to a Panel, the size will be a size dp square instead.

This is in contrast to SubspaceModifier.size, which respects the parent's constraints. requiredSize will ignore all min and max constraints from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds.

Parameters

size required size in Dp for all dimensions.

requiredSize

Source set: Android
public fun SubspaceModifier.requiredSize(size: DpVolumeSize): SubspaceModifier

Declare the size of the content to be exactly size in each of the three dimensions of the Composable's local coordinate space, disregarding the incoming VolumeConstraints.

This is in contrast to SubspaceModifier.size, which respects the parent's constraints. requiredSize will ignore all min and max constraints from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds. The parent will then determine how to handle the overflow.

Parameters

size required volume size as a DpVolumeSize.

requiredSize

Source set: Android
public fun SubspaceModifier.requiredSize(
    width: Dp = Dp.Unspecified,
    height: Dp = Dp.Unspecified,
    depth: Dp = Dp.Unspecified,
): SubspaceModifier

Declare the size of the content to be exactly width, height, and depth in each of the three dimensions of the Composable's local coordinate space, disregarding the incoming VolumeConstraints.

This is in contrast to SubspaceModifier.size, which respects the parent's constraints. requiredSize will ignore all min and max constraints from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds. The parent will then determine how to handle the overflow.

Parameters

width required width in Dp.
height required height in Dp.
depth required depth in Dp.

Last updated: