SubspaceModifier

interface SubspaceModifier

Known direct subclasses
SubspaceModifier.Companion

The companion object SubspaceModifier is the empty, default, or starter SubspaceModifier that contains no SubspaceModifierNodeElements.

SubspaceModifierNodeElement

Modifier elements manage an instance of a particular SubspaceModifier.Node implementation.


An ordered, immutable collection of subspace modifier elements that decorate or add behavior to Subspace Compose elements.

Based on androidx.compose.ui.Modifier

Summary

Nested types

The companion object SubspaceModifier is the empty, default, or starter SubspaceModifier that contains no SubspaceModifierNodeElements.

The longer-lived object that is created for each SubspaceModifierNodeElement applied to a SubspaceLayout

Public companion functions

infix SubspaceModifier
open String

Public functions

open Boolean

Returns true if predicate returns true for all SubspaceModifierNodeElements in this SubspaceModifier or if this SubspaceModifier contains no Elements.

open Boolean

Returns true if predicate returns true for any SubspaceModifierNodeElement in this SubspaceModifier.

open R
<R : Any?> foldIn(
    initial: R,
    operation: (SubspaceModifierNodeElement<SubspaceModifier.Node>, R) -> R
)

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierNodeElement from outside in.

open R
<R : Any?> foldOut(
    initial: R,
    operation: (SubspaceModifierNodeElement<SubspaceModifier.Node>, R) -> R
)

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierNodeElement from inside out.

open infix SubspaceModifier

Concatenates this modifier with another.

Extension functions

SubspaceModifier
SubspaceModifier.alpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the opacity of this element (and its children) to a value between 0..1.

SubspaceModifier
SubspaceModifier.aspectRatio(
    ratio: @FloatRange(from = 0.0, fromInclusive = false) Float,
    matchHeightConstraintsFirst: Boolean
)

Attempts to size the content to match a specified aspect ratio by trying to match one of the incoming constraints in the following order: VolumeConstraints.maxWidth, VolumeConstraints.maxHeight, VolumeConstraints.minWidth, VolumeConstraints.minHeight if matchHeightConstraintsFirst is false (which is the default), or VolumeConstraints.maxHeight, VolumeConstraints.maxWidth, VolumeConstraints.minHeight, VolumeConstraints.minWidth if matchHeightConstraintsFirst is true.

SubspaceModifier
SubspaceModifier.movable(
    enabled: Boolean,
    stickyPose: Boolean,
    scaleWithDistance: Boolean,
    onMoveStart: ((SpatialMoveStartEvent) -> Unit)?,
    onMoveEnd: ((SpatialMoveEndEvent) -> Unit)?,
    onMove: ((SpatialMoveEvent) -> Boolean)?
)

This function is deprecated. The movable modifier is now deprecated.

SubspaceModifier
SubspaceModifier.offset(x: Dp, y: Dp, z: Dp)

Offset the content by (x dp, y dp, z dp).

SubspaceModifier

Invoke onGloballyPositioned with the SubspaceLayoutCoordinates of the element when the global position or the orientation of the content may have changed.

SubspaceModifier
SubspaceModifier.onPointSourceParamsAvailable(
    onPointSourceParamsAvailable: (PointSourceParams) -> Unit
)

Used to provide a PointSourceParams to allow specifying the modified Composable as an audio source.

SubspaceModifier

Apply all dp of additional space along each edge of the content, left, top, right, bottom, front, and back.

SubspaceModifier
SubspaceModifier.padding(horizontal: Dp, vertical: Dp, depth: Dp)

Apply horizontal dp space along the left and right edges of the content, vertical dp space along the top and bottom edges, and depth dp space along front and back edged.

SubspaceModifier
SubspaceModifier.padding(
    left: Dp,
    top: Dp,
    right: Dp,
    bottom: Dp,
    front: Dp,
    back: Dp
)

Apply additional space along each edge of the content in Dp: left, top, right, bottom, front and back.

SubspaceModifier

When present, this modifier defines how the pointer icon will be displayed when the spatial pointer hovers over an element.

SubspaceModifier
SubspaceModifier.resizable(
    enabled: Boolean,
    minimumSize: DpVolumeSize,
    maximumSize: DpVolumeSize,
    maintainAspectRatio: Boolean,
    onSizeChange: ((IntVolumeSize) -> Boolean)?
)

This function is deprecated. The Resizable modifier is now deprecated.

SubspaceModifier

Rotate a subspace element (i.e. Panel) in space with regards to the center of the element.

SubspaceModifier
SubspaceModifier.rotate(axisAngle: Vector3, rotation: Float)

Rotate a subspace element (i.e. Panel) in space with regards to the center of the element.

SubspaceModifier
SubspaceModifier.rotate(pitch: Float, yaw: Float, roll: Float)

Rotate a subspace element (i.e. Panel) in space with regards to the center of the element.

SubspaceModifier

Scale the contents of the composable by the scale factor along horizontal, vertical, and depth axes.

SubspaceModifier

Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc.

SubspaceModifier

Declare the preferred size of the content to be exactly depth dp along the z dimension.

SubspaceModifier
SubspaceModifier.depthIn(min: Dp, max: Dp)

Constrain the depth of the content to be between mindp and maxdp as permitted by the incoming measurement constraints.

SubspaceModifier
SubspaceModifier.fillMaxDepth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
)

Have the content fill (possibly only partially) the VolumeConstraints.maxDepth of the incoming measurement constraints, by setting the minimum depth and the maximum depth to be equal to the maximum depth multiplied by fraction.

SubspaceModifier
SubspaceModifier.fillMaxHeight(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
)

Have the content fill (possibly only partially) the VolumeConstraints.maxHeight of the incoming measurement constraints, by setting the minimum height and the maximum height to be equal to the maximum height multiplied by fraction.

SubspaceModifier
SubspaceModifier.fillMaxSize(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
)

Have the content fill (possibly only partially) the VolumeConstraints.maxWidth, VolumeConstraints.maxHeight, and VolumeConstraints.maxDepth of the incoming measurement constraints.

SubspaceModifier
SubspaceModifier.fillMaxWidth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
)

Have the content fill (possibly only partially) the VolumeConstraints.maxWidth of the incoming measurement constraints, by setting the minimum width and the maximum width to be equal to the maximum width multiplied by fraction.

SubspaceModifier

Declare the preferred size of the content to be exactly height dp along the y dimension.

SubspaceModifier

Constrain the height of the content to be between mindp and maxdp as permitted by the incoming measurement constraints.

SubspaceModifier

Declare the size of the content to be exactly depth dp along the z dimension, disregarding the incoming VolumeConstraints.

SubspaceModifier

Declare the size of the content to be exactly height dp along the y dimension, disregarding the incoming VolumeConstraints.

SubspaceModifier

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

SubspaceModifier

Declare the size of the content to be exactly size in each of the three dimensions, disregarding the incoming VolumeConstraints.

SubspaceModifier

Declare the size of the content to be exactly width dp along the x dimension, disregarding the incoming VolumeConstraints.

SubspaceModifier

Declare the preferred size of the content to be exactly a size dp cube.

SubspaceModifier

Declare the preferred size of the content to be exactly size in each of the three dimensions.

SubspaceModifier
SubspaceModifier.sizeIn(
    minWidth: Dp,
    maxWidth: Dp,
    minHeight: Dp,
    maxHeight: Dp,
    minDepth: Dp,
    maxDepth: Dp
)

Constrain the size of the content to be between min and max dp as permitted by the incoming measurement constraints.

SubspaceModifier

Declare the preferred size of the content to be exactly width dp along the x dimension.

SubspaceModifier
SubspaceModifier.widthIn(min: Dp, max: Dp)

Constrain the width of the content to be between mindp and maxdp as permitted by the incoming measurement constraints.

SubspaceModifier

Applies a tag to allow modified element to be found in tests.

Public companion functions

toString

open fun toString(): String

Public functions

all

Added in 1.0.0-alpha07
open fun all(
    predicate: (SubspaceModifierNodeElement<SubspaceModifier.Node>) -> Boolean
): Boolean

Returns true if predicate returns true for all SubspaceModifierNodeElements in this SubspaceModifier or if this SubspaceModifier contains no Elements.

any

Added in 1.0.0-alpha07
open fun any(
    predicate: (SubspaceModifierNodeElement<SubspaceModifier.Node>) -> Boolean
): Boolean

Returns true if predicate returns true for any SubspaceModifierNodeElement in this SubspaceModifier.

foldIn

Added in 1.0.0-alpha07
open fun <R : Any?> foldIn(
    initial: R,
    operation: (SubspaceModifierNodeElement<SubspaceModifier.Node>, R) -> R
): R

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierNodeElement from outside in.

foldOut

Added in 1.0.0-alpha07
open fun <R : Any?> foldOut(
    initial: R,
    operation: (SubspaceModifierNodeElement<SubspaceModifier.Node>, R) -> R
): R

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierNodeElement from inside out.

then

Added in 1.0.0-alpha07
open infix fun then(other: SubspaceModifier): SubspaceModifier

Concatenates this modifier with another.

Returns a SubspaceModifier representing this modifier followed by other in sequence.

Extension functions

fun SubspaceModifier.alpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float): SubspaceModifier

Sets the opacity of this element (and its children) to a value between 0..1. An alpha value of 0.0f means fully transparent while a value of 1.0f is completely opaque. Elements with semi-transparent alpha values (> 0.0 but < 1.0f) will be rendered using alpha-blending.

Parameters
alpha: @FloatRange(from = 0.0, to = 1.0) Float

the opacity of this element (and its children). Must be a value between 0 and 1, inclusive. Values < 0 or 1 will be clamped.

fun SubspaceModifier.aspectRatio(
    ratio: @FloatRange(from = 0.0, fromInclusive = false) Float,
    matchHeightConstraintsFirst: Boolean = false
): SubspaceModifier

Attempts to size the content to match a specified aspect ratio by trying to match one of the incoming constraints in the following order: VolumeConstraints.maxWidth, VolumeConstraints.maxHeight, VolumeConstraints.minWidth, VolumeConstraints.minHeight if matchHeightConstraintsFirst is false (which is the default), or VolumeConstraints.maxHeight, VolumeConstraints.maxWidth, VolumeConstraints.minHeight, VolumeConstraints.minWidth if matchHeightConstraintsFirst is true. The size in the other dimension is determined by the aspect ratio. The combinations will be tried in this order until one non-empty is found to satisfy the constraints. If no valid size is obtained this way, it means that there is no non-empty size satisfying both the constraints and the aspect ratio, so the constraints will not be respected and the content will be sized such that the VolumeConstraints.maxWidth or VolumeConstraints.maxHeight is matched (depending on matchHeightConstraintsFirst). Note that this modifier constrains the ratio between the content's width and height only. The depth dimension is not affected or constrained by this aspect ratio modifier.

Example usage:

SpatialPanel(SubspaceModifier.width(100.dp).aspectRatio(16f / 9f)) {
Text(text = "Inner Composable Content")
}
Parameters
ratio: @FloatRange(from = 0.0, fromInclusive = false) Float

the desired width/height positive ratio

matchHeightConstraintsFirst: Boolean = false

if true, height constraints will be matched before width constraints and used to calculate the resulting size according to ratio

fun SubspaceModifier.movable(
    enabled: Boolean = true,
    stickyPose: Boolean = false,
    scaleWithDistance: Boolean = true,
    onMoveStart: ((SpatialMoveStartEvent) -> Unit)? = null,
    onMoveEnd: ((SpatialMoveEndEvent) -> Unit)? = null,
    onMove: ((SpatialMoveEvent) -> Boolean)? = null
): SubspaceModifier

When the movable modifier is present and enabled, draggable UI controls will be shown that allow the user to move the element in 3D space. This feature is only available for SpatialPanels at the moment.

Parameters
enabled: Boolean = true

true if this composable should be movable.

stickyPose: Boolean = false

if enabled, the user specified position will be retained when the modifier is disabled or removed.

scaleWithDistance: Boolean = true

true if this composable should scale in size when moved in depth. When this scaleWithDistance is enabled, the subspace element moved will grow or shrink. It will also maintain any explicit scale that it had before movement.

onMoveStart: ((SpatialMoveStartEvent) -> Unit)? = null

a callback to process the start of a move event. This will only be called if enabled is true. The callback will be called with the SpatialMoveStartEvent type

onMoveEnd: ((SpatialMoveEndEvent) -> Unit)? = null

a callback to process the end of a move event. This will only be called if enabled is true. The callback will be called with the SpatialMoveEndEvent type

onMove: ((SpatialMoveEvent) -> Boolean)? = null

a callback to process the pose change during movement, with translation in pixels. This will only be called if enabled is true. If the callback returns false the default behavior of moving this composable's subspace hierarchy will be executed. If it returns true, it is the responsibility of the callback to process the event. The callback will be called with the SpatialMoveEvent type.

See also
SpatialMoveEvent

.

fun SubspaceModifier.offset(x: Dp = 0.dp, y: Dp = 0.dp, z: Dp = 0.dp): SubspaceModifier

Offset the content by (x dp, y dp, z dp). The offsets can be positive as well as non-positive.

onGloballyPositioned

fun SubspaceModifier.onGloballyPositioned(
    onGloballyPositioned: (SubspaceLayoutCoordinates) -> Unit
): SubspaceModifier

Invoke onGloballyPositioned with the SubspaceLayoutCoordinates of the element when the global position or the orientation of the content may have changed. Note that it will be called after a composition when the coordinates are finalized.

This callback executes after composition once the final coordinates are determined. It will be invoked at least once when the SubspaceLayoutCoordinates become available and subsequently whenever the composable's transform (position, rotation, scale) is updated relative to the subspace's origin.

The callback information will be relative to its subspace. For instance, When a nested subspace is moved by the global subspace its Pose will reflect its position in the nested subspace. Its position value will not be updated despite moving locations in the Global Subspace.

onPointSourceParamsAvailable

fun SubspaceModifier.onPointSourceParamsAvailable(
    onPointSourceParamsAvailable: (PointSourceParams) -> Unit
): SubspaceModifier

Used to provide a PointSourceParams to allow specifying the modified Composable as an audio source. See PointSourceParams for more info on how to attach this object to a media source.

PointSourceParams are used to configure a sound to be spatialized as a point in 3D space. This is to override the default behavior where sound is played from the SpatialMainPanel.

import androidx.compose.foundation.AndroidExternalSurface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.xr.compose.platform.LocalSession
import androidx.xr.compose.subspace.MovePolicy
import androidx.xr.compose.subspace.SpatialPanel
import androidx.xr.compose.subspace.SubspaceComposable
import androidx.xr.compose.subspace.layout.SubspaceModifier
import androidx.xr.compose.subspace.layout.onPointSourceParamsAvailable
import androidx.xr.compose.subspace.layout.size
import androidx.xr.scenecore.SpatialMediaPlayer

@Composable
@SubspaceComposable
fun MediaPlayerInSpatialPanel(mediaUri: Uri) {
    val session = LocalSession.current
    val context = LocalContext.current
    val mediaPlayer = remember { MediaPlayer() }
    val paramsSet = remember { mutableStateOf(false) }

    SpatialPanel(
        SubspaceModifier.size(400.dp).onPointSourceParamsAvailable {
            if (!paramsSet.value) {
                paramsSet.value = true
                mediaPlayer.setDataSource(context, mediaUri)
                SpatialMediaPlayer.setPointSourceParams(session!!, mediaPlayer, it)
                mediaPlayer.prepare()
                mediaPlayer.start()
            }
        },
        dragPolicy = MovePolicy(),
    ) {
        DisposableEffect(Unit) { onDispose { mediaPlayer.release() } }

        // Use this for playing video, or omit it for audio only use cases.
        AndroidExternalSurface {
            onSurface { surface, _, _ -> mediaPlayer.setSurface(surface) }
        }
    }
}
Parameters
onPointSourceParamsAvailable: (PointSourceParams) -> Unit

Will be called with a PointSourceParams once it is generated.

fun SubspaceModifier.padding(all: Dp): SubspaceModifier

Apply all dp of additional space along each edge of the content, left, top, right, bottom, front, and back. Padding is applied before content measurement and takes precedence; content may only be as large as the remaining space.

Negative padding is not permitted — it will cause IllegalArgumentException. See padding

fun SubspaceModifier.padding(
    horizontal: Dp = 0.dp,
    vertical: Dp = 0.dp,
    depth: Dp = 0.dp
): SubspaceModifier

Apply horizontal dp space along the left and right edges of the content, vertical dp space along the top and bottom edges, and depth dp space along front and back edged. Padding is applied before content measurement and takes precedence; content may only be as large as the remaining space.

Negative padding is not permitted — it will cause IllegalArgumentException. See padding

fun SubspaceModifier.padding(
    left: Dp = 0.dp,
    top: Dp = 0.dp,
    right: Dp = 0.dp,
    bottom: Dp = 0.dp,
    front: Dp = 0.dp,
    back: Dp = 0.dp
): SubspaceModifier

Apply additional space along each edge of the content in Dp: left, top, right, bottom, front and back. Padding is applied before content measurement and takes precedence; content may only be as large as the remaining space.

Negative padding is not permitted — it will cause IllegalArgumentException.

pointerHoverIcon

fun SubspaceModifier.pointerHoverIcon(icon: SpatialPointerIcon): SubspaceModifier

When present, this modifier defines how the pointer icon will be displayed when the spatial pointer hovers over an element. Any child elements will inherit the pointer icon setting that this modifier defines for their parent element upon hovering.

Parameters
icon: SpatialPointerIcon

The SpatialPointerIcon to be displayed on hover.

Returns
SubspaceModifier

A SubspaceModifier that includes the hover icon behavior.

fun SubspaceModifier.resizable(
    enabled: Boolean = true,
    minimumSize: DpVolumeSize = DpVolumeSize.Zero,
    maximumSize: DpVolumeSize = DpVolumeSize(Dp.Infinity, Dp.Infinity, Dp.Infinity),
    maintainAspectRatio: Boolean = false,
    onSizeChange: ((IntVolumeSize) -> Boolean)? = null
): SubspaceModifier

When the resizable modifier is present and enabled, draggable UI controls will be shown that allow the user to resize the element in 3D space. This feature is only available for instances of SpatialPanel at the moment.

Parameters
enabled: Boolean = true

true if this composable should be resizable.

minimumSize: DpVolumeSize = DpVolumeSize.Zero

the smallest allowed dimensions for this composable.

maximumSize: DpVolumeSize = DpVolumeSize(Dp.Infinity, Dp.Infinity, Dp.Infinity)

the largest allowed dimensions for this composable.

maintainAspectRatio: Boolean = false

true if the new size should maintain the same aspect ratio as the existing size.

onSizeChange: ((IntVolumeSize) -> Boolean)? = null

a callback to process the size change in pixels during resizing. This will only be called if enabled is true. If the callback returns false or isn't specified, the default behavior of resizing this composable will be executed. If it returns true, it is the responsibility of the callback to process the event.

TODO(b/427974119): Investigate fix for resizing from size Zero.

fun SubspaceModifier.rotate(quaternion: Quaternion): SubspaceModifier

Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. The rotation is directly specified by the provided Quaternion. The Quaternion values are specified as x,y,z,w. Where w is the rotation of the unit vector, in radians.

Parameters
quaternion: Quaternion

Quaternion describing the rotation.

fun SubspaceModifier.rotate(axisAngle: Vector3, rotation: Float): SubspaceModifier

Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. The rotation is defined by a Vector3 and a rotation angle in degrees. The axis angle will be normalized during construction. The rotation will be applied to the unit vector representing the axisAngle.

Parameters
axisAngle: Vector3

Vector representing the axis of rotation.

rotation: Float

Degrees of rotation.

fun SubspaceModifier.rotate(pitch: Float, yaw: Float, roll: Float): SubspaceModifier

Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. Parameter rotation angles are specified in degrees. The rotations are applied with the order pitch, then yaw, then roll.

Parameters
pitch: Float

Rotation around the x-axis. The x-axis is the axis width is measured on.

yaw: Float

Rotation around the y-axis. The y-axis is the axis height is measured on.

roll: Float

Rotation around the z-axis. The z-axis is the axis depth is measured on.

fun SubspaceModifier.scale(scale: Float): SubspaceModifier

Scale the contents of the composable by the scale factor along horizontal, vertical, and depth axes. Scaling does not change the measured size of the composable content during layout. Measured size of SubspaceComposable elements can be controlled using size Modifiers. Scale factor should be a positive number.

Parameters
scale: Float

Multiplier to scale content along vertical, horizontal, depth axes.

fun SubspaceModifier.semantics(properties: SemanticsPropertyReceiver.() -> Unit): SubspaceModifier

Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc.

Based on androidx.compose.ui.semantics.SemanticsModifier.

fun SubspaceModifier.depth(depth: Dp): SubspaceModifier

Declare the preferred size of the content to be exactly depth dp along the z dimension. Panels have 0 depth and ignore this modifier.

fun SubspaceModifier.depthIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified): SubspaceModifier

Constrain the depth of the content to be between mindp and maxdp as permitted by the incoming measurement constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.

Parameters
min: Dp = Dp.Unspecified

The minimum depth.

max: Dp = Dp.Unspecified

The maximum depth.

fillMaxDepth

fun SubspaceModifier.fillMaxDepth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
): SubspaceModifier

Have the content fill (possibly only partially) the VolumeConstraints.maxDepth of the incoming measurement constraints, by setting the minimum depth and the maximum depth to be equal to the maximum depth multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available depth. If the incoming maximum depth is VolumeConstraints.Infinity this modifier will have no effect.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

The fraction of the maximum height to use, between 0 and 1, inclusive.

fillMaxHeight

fun SubspaceModifier.fillMaxHeight(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
): SubspaceModifier

Have the content fill (possibly only partially) the VolumeConstraints.maxHeight of the incoming measurement constraints, by setting the minimum height and the maximum height to be equal to the maximum height multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available height. If the incoming maximum height is VolumeConstraints.Infinity this modifier will have no effect.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

The fraction of the maximum height to use, between 0 and 1, inclusive.

fun SubspaceModifier.fillMaxSize(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
): SubspaceModifier

Have the content fill (possibly only partially) the VolumeConstraints.maxWidth, VolumeConstraints.maxHeight, and VolumeConstraints.maxDepth of the incoming measurement constraints. See SubspaceModifier.fillMaxWidth, SubspaceModifier.fillMaxHeight, and SubspaceModifier.fillMaxDepth for details. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available space. If the incoming maximum width or height or depth is VolumeConstraints.Infinity this modifier will have no effect in that dimension.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

The fraction of the maximum size to use, between 0 and 1, inclusive.

fillMaxWidth

fun SubspaceModifier.fillMaxWidth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
): SubspaceModifier

Have the content fill (possibly only partially) the VolumeConstraints.maxWidth of the incoming measurement constraints, by setting the minimum width and the maximum width to be equal to the maximum width multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available width. If the incoming maximum width is VolumeConstraints.Infinity this modifier will have no effect.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

The fraction of the maximum width to use, between 0 and 1, inclusive.

fun SubspaceModifier.height(height: Dp): SubspaceModifier

Declare the preferred size of the content to be exactly height dp along the y dimension.

fun SubspaceModifier.heightIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified): SubspaceModifier

Constrain the height of the content to be between mindp and maxdp as permitted by the incoming measurement constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.

Parameters
min: Dp = Dp.Unspecified

The minimum height.

max: Dp = Dp.Unspecified

The maximum height.

requiredDepth

fun SubspaceModifier.requiredDepth(depth: Dp): SubspaceModifier

Declare the size of the content to be exactly depth dp along the z dimension, disregarding the incoming VolumeConstraints.

This is in contrast to SubspaceModifier.depth, which respects the parent's constraints. requiredDepth will ignore the minDepth and maxDepth from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds.

requiredHeight

fun SubspaceModifier.requiredHeight(height: Dp): SubspaceModifier

Declare the size of the content to be exactly height dp along the y dimension, disregarding the incoming VolumeConstraints.

This is in contrast to SubspaceModifier.height, which respects the parent's constraints. requiredHeight will ignore the minHeight and maxHeight from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds.

requiredSize

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.

requiredSize

fun SubspaceModifier.requiredSize(size: DpVolumeSize): SubspaceModifier

Declare the size of the content to be exactly size in each of the three dimensions, disregarding the incoming VolumeConstraints. Panels have 0 depth and ignore the z-component of this modifier.

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.

requiredWidth

fun SubspaceModifier.requiredWidth(width: Dp): SubspaceModifier

Declare the size of the content to be exactly width dp along the x dimension, disregarding the incoming VolumeConstraints.

This is in contrast to SubspaceModifier.width, which respects the parent's constraints. requiredWidth will ignore the minWidth and maxWidth from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds.

fun SubspaceModifier.size(size: Dp): SubspaceModifier

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

fun SubspaceModifier.size(size: DpVolumeSize): SubspaceModifier

Declare the preferred size of the content to be exactly size in each of the three dimensions. Panels have 0 depth and ignore the z-component of this modifier.

fun SubspaceModifier.sizeIn(
    minWidth: Dp = Dp.Unspecified,
    maxWidth: Dp = Dp.Unspecified,
    minHeight: Dp = Dp.Unspecified,
    maxHeight: Dp = Dp.Unspecified,
    minDepth: Dp = Dp.Unspecified,
    maxDepth: Dp = Dp.Unspecified
): SubspaceModifier

Constrain the size of the content to be between min and max dp as permitted by the incoming measurement constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.

Parameters
minWidth: Dp = Dp.Unspecified

The minimum width.

maxWidth: Dp = Dp.Unspecified

The maximum width.

minHeight: Dp = Dp.Unspecified

The minimum height.

maxHeight: Dp = Dp.Unspecified

The maximum height.

minDepth: Dp = Dp.Unspecified

The minimum depth.

maxDepth: Dp = Dp.Unspecified

The maximum depth.

fun SubspaceModifier.width(width: Dp): SubspaceModifier

Declare the preferred size of the content to be exactly width dp along the x dimension.

fun SubspaceModifier.widthIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified): SubspaceModifier

Constrain the width of the content to be between mindp and maxdp as permitted by the incoming measurement constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.

Parameters
min: Dp = Dp.Unspecified

The minimum width.

max: Dp = Dp.Unspecified

The maximum width.

fun SubspaceModifier.testTag(tag: String): SubspaceModifier

Applies a tag to allow modified element to be found in tests.

This is a convenience method for a semantics that sets SemanticsPropertyReceiver.testTag.