SubspaceModifier
interface SubspaceModifier
SubspaceModifier.Companion |
The companion object |
SubspaceModifierNodeElement |
Modifier elements manage an instance of a particular |
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 |
abstract class SubspaceModifier.Node : DelegatableSubspaceNodeThe longer-lived object that is created for each |
Public companion functions |
|
|---|---|
infix SubspaceModifier |
|
open String |
toString() |
Public functions |
|
|---|---|
open Boolean |
all(Returns |
open Boolean |
any(Returns |
open R |
<R : Any?> foldIn(Accumulates a value starting with |
open R |
<R : Any?> foldOut(Accumulates a value starting with |
open infix SubspaceModifier |
then(other: 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(Attempts to size the content to match a specified aspect ratio by trying to match one of the incoming constraints in the following order: |
SubspaceModifier |
A |
SubspaceModifier |
SubspaceModifier.layout(Creates a node that allows changing how the wrapped element is measured and laid out. |
SubspaceModifier |
SubspaceModifier.billboard(enabled: Boolean)A |
SubspaceModifier |
SubspaceModifier.lookAtUser(enabled: Boolean, up: Vector3)A |
SubspaceModifier |
SubspaceModifier.offset(x: Dp, y: Dp, z: Dp) |
SubspaceModifier |
SubspaceModifier.onGloballyPositioned(Invoke |
SubspaceModifier |
SubspaceModifier.onPointSourceParamsAvailable(Used to provide a |
SubspaceModifier |
SubspaceModifier.onSizeChanged(Invokes |
SubspaceModifier |
SubspaceModifier.padding(all: Dp)Apply |
SubspaceModifier |
SubspaceModifier.padding(horizontal: Dp, vertical: Dp, depth: Dp)Apply |
SubspaceModifier |
Apply additional space along each edge of the content in |
SubspaceModifier |
When present, this modifier defines how the pointer icon will be displayed when the spatial pointer hovers over an element. |
SubspaceModifier |
SubspaceModifier.rotate(quaternion: Quaternion)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 |
SubspaceModifier.scale(scale: Float)Scale the contents of the composable by the scale factor along horizontal, vertical, and depth axes. |
SubspaceModifier |
SubspaceModifier.semantics(properties: SemanticsPropertyReceiver.() -> Unit)Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc. |
SubspaceModifier |
SubspaceModifier.depth(depth: Dp)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.depthIn(min: Dp, max: Dp)Constrain the depth of the content to be between |
SubspaceModifier |
SubspaceModifier.fillMaxDepth(Have the content fill (possibly only partially) the |
SubspaceModifier |
SubspaceModifier.fillMaxHeight(Have the content fill (possibly only partially) the |
SubspaceModifier |
SubspaceModifier.fillMaxSize(Have the content fill (possibly only partially) the |
SubspaceModifier |
SubspaceModifier.fillMaxWidth(Have the content fill (possibly only partially) the |
SubspaceModifier |
SubspaceModifier.height(height: Dp)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.heightIn(min: Dp, max: Dp)Constrain the height of the content to be between |
SubspaceModifier |
SubspaceModifier.requiredDepth(depth: Dp)Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredDepthIn(min: Dp, max: Dp)Constrain the depth of the content to be between |
SubspaceModifier |
SubspaceModifier.requiredHeight(height: Dp)Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredHeightIn(min: Dp, max: Dp)Constrain the height of the content to be between |
SubspaceModifier |
SubspaceModifier.requiredSize(size: Dp)Declare the size of the content to be exactly a |
SubspaceModifier |
Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredSize(width: Dp, height: Dp, depth: Dp)Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredSizeIn(Constrain the size of the content to be between min and max dp, disregarding the incoming measurement |
SubspaceModifier |
SubspaceModifier.requiredWidth(width: Dp)Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredWidthIn(min: Dp, max: Dp)Constrain the width of the content to be between |
SubspaceModifier |
SubspaceModifier.size(size: Dp)Declare the preferred size of the content to be exactly a |
SubspaceModifier |
SubspaceModifier.size(size: DpVolumeSize)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.size(width: Dp, height: Dp, depth: Dp)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.sizeIn(Constrain the size of the content to be between min and max dp as permitted by the incoming measurement constraints. |
SubspaceModifier |
SubspaceModifier.width(width: Dp)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.widthIn(min: Dp, max: Dp)Constrain the width of the content to be between |
SubspaceModifier |
SubspaceModifier.testTag(tag: String)Applies a tag to allow modified element to be found in tests. |
Public companion functions
then
infix fun then(other: SubspaceModifierNodeElement<SubspaceModifier.Node>): SubspaceModifier
Public functions
all
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
open fun any(
predicate: (SubspaceModifierNodeElement<SubspaceModifier.Node>) -> Boolean
): Boolean
Returns true if predicate returns true for any SubspaceModifierNodeElement in this SubspaceModifier.
foldIn
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
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
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
alpha
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. |
aspectRatio
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 |
gravityAligned
fun SubspaceModifier.gravityAligned(): SubspaceModifier
A SubspaceModifier that forces the content to remain upright, aligned with gravity by isolating the element's yaw by cancelling parent pitch and roll.
This modifier calculates the necessary counter-rotation to ignore the pitch and roll of its parent entity's total world transformation. It only affects the rotation and not the translation. This is useful for UI elements like labels or billboards that should always stay level, regardless of the orientation of the object they are attached to. It effectively isolates the yaw (rotation around the vertical Y-axis).
layout
fun SubspaceModifier.layout(
measure: SubspaceMeasureScope.(SubspaceMeasurable, VolumeConstraints) -> SubspaceMeasureResult
): SubspaceModifier
Creates a node that allows changing how the wrapped element is measured and laid out.
billboard
fun SubspaceModifier.billboard(enabled: Boolean = true): SubspaceModifier
A SubspaceModifier that forces the content to remain upright and will rotate on the y-axis that the content faces the user at all times.
A user of this API should configure the activity's Session object with Config.HeadTrackingMode.LAST_KNOWN which requires android.permission.HEAD_TRACKING Android permission be granted by the calling application. session.configure( config = session.config.copy(headTracking = Config.HeadTrackingMode.LAST_KNOWN) )
| Parameters | |
|---|---|
enabled: Boolean = true |
true if this composable should always face the user. |
| See also | |
|---|---|
lookAtUser |
modifier for making content that will tilt in all directions to face the user. |
lookAtUser
fun SubspaceModifier.lookAtUser(
enabled: Boolean = true,
up: Vector3 = Vector3(0f, 1f, 0f)
): SubspaceModifier
A SubspaceModifier that continuously rotates content so that it faces the user at all times.
A user of this API should configure the activity's Session object with Config.HeadTrackingMode.LAST_KNOWN which requires android.permission.HEAD_TRACKING Android permission be granted by the calling application. session.configure( config = session.config.copy(headTracking = Config.HeadTrackingMode.LAST_KNOWN) )
| Parameters | |
|---|---|
enabled: Boolean = true |
true if this composable should always face the user. |
up: Vector3 = Vector3(0f, 1f, 0f) |
Indicates which direction is "up" when orienting the content upright. LookAtUser makes the front of the content face the user. But this can be accomplished with the content sitting upright, upside-down or any rotation in-between. "up" addresses that ambiguity. By default, up is 0,1,0. |
| See also | |
|---|---|
billboard |
modifier for making content that will generally face the user's direction but keeps the content in an upright position. |
offset
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 |
onSizeChanged
fun SubspaceModifier.onSizeChanged(
onSizeChanged: (size: IntVolumeSize) -> Unit
): SubspaceModifier
Invokes onSizeChanged with the IntVolumeSize of the element when its size changes.
This callback is executed after the layout pass when the SubspaceComposable's size is finalized. It will be invoked at least once when the size becomes available and subsequently whenever the size changes.
For observing changes to position or orientation in addition to size, use SubspaceModifier.onGloballyPositioned instead.
| Parameters | |
|---|---|
onSizeChanged: (size: IntVolumeSize) -> Unit |
The callback that is invoked when the size changes. The |
padding
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
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
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 |
| Returns | |
|---|---|
SubspaceModifier |
A |
rotate
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. |
rotate
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.
rotate
fun SubspaceModifier.rotate(pitch: Float = 0.0f, yaw: Float = 0.0f, roll: Float = 0.0f): 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. If no values are provided, no rotation is applied.
| Parameters | |
|---|---|
pitch: Float = 0.0f |
Rotation around the x-axis. Defaults to |
yaw: Float = 0.0f |
Rotation around the y-axis. Defaults to |
roll: Float = 0.0f |
Rotation around the z-axis. Defaults to |
scale
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. |
semantics
fun SubspaceModifier.semantics(properties: SemanticsPropertyReceiver.() -> Unit): SubspaceModifier
Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc.
depth
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.
depthIn
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.
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 |
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 |
fillMaxSize
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 |
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 |
height
fun SubspaceModifier.height(height: Dp): SubspaceModifier
Declare the preferred size of the content to be exactly height dp along the y dimension.
heightIn
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.
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.
requiredDepthIn
fun SubspaceModifier.requiredDepthIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
): SubspaceModifier
Constrain the depth of the content to be between min dp and max dp, disregarding the incoming measurement VolumeConstraints.
This is in contrast to SubspaceModifier.depthIn, which respects the parent's constraints. requiredDepthIn will ignore the minDepth and maxDepth from the incoming constraints.
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.
requiredHeightIn
fun SubspaceModifier.requiredHeightIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
): SubspaceModifier
Constrain the height of the content to be between min dp and max dp, disregarding the incoming measurement VolumeConstraints.
This is in contrast to SubspaceModifier.heightIn, which respects the parent's constraints. requiredHeightIn will ignore the minHeight and maxHeight from the incoming constraints.
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.
requiredSize
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, 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.
requiredSizeIn
fun SubspaceModifier.requiredSizeIn(
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, disregarding the incoming measurement VolumeConstraints.
This is in contrast to SubspaceModifier.sizeIn, which respects the parent's constraints. requiredSizeIn will ignore the min and max constraints from the incoming constraints, which can be useful for sizing an element to a specific range even if it exceeds the parent's bounds.
| 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. |
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.
requiredWidthIn
fun SubspaceModifier.requiredWidthIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
): SubspaceModifier
Constrain the width of the content to be between min dp and max dp, disregarding the incoming measurement VolumeConstraints.
This is in contrast to SubspaceModifier.widthIn, which respects the parent's constraints. requiredWidthIn will ignore the minWidth and maxWidth from the incoming constraints.
size
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.
size
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.
size
fun SubspaceModifier.size(
width: Dp = Dp.Unspecified,
height: Dp = Dp.Unspecified,
depth: Dp = Dp.Unspecified
): SubspaceModifier
Declare the preferred size of the content to be exactly width dp along the x dimensions, height dp along the y dimensions, and depth dp along the z dimension.
sizeIn
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. |
width
fun SubspaceModifier.width(width: Dp): SubspaceModifier
Declare the preferred size of the content to be exactly width dp along the x dimension.
widthIn
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.
testTag
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.