[null,null,["最后更新时间 (UTC):2025-07-31。"],[],[],null,["# Subspace modifiers\n\nA [`SubspaceModifier`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier) is similar to a [Compose modifier](/develop/ui/compose/modifiers) for composables\nin a [`Subspace`](/develop/xr/jetpack-xr-sdk/add-subspace). A `SubspaceModifier` lets you manipulate composables in 3D\nspace, helping you position, rotate, and add behaviors to 3D layout nodes.\n\nLayout\n------\n\nBy default, a `Subspace` is [bounded by the recommended space for viewing an\napp](/develop/xr/jetpack-xr-sdk/add-subspace#subspace-hierarchies). These bounds are used when measuring the layout of your subspace\ncomponents, similar to [bounds in 2D Compose layouts](/develop/ui/compose/layouts/constraints-modifiers).\n\n### Fill bounds\n\nThe modifiers [`fillMaxSize`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).fillMaxSize(kotlin.Float)), [`fillMaxWidth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).fillMaxWidth(kotlin.Float)), [`fillMaxHeight`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).fillMaxHeight(kotlin.Float)), and\n[`fillMaxDepth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).fillMaxDepth(kotlin.Float)) make content (partially) fill the bounds of its parent.\nUsing fill modifiers helps your app layout content that's independent of the XR\ndevice's display characteristics.\n\n### Set the size and required size\n\nThe modifiers [`size`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).size(androidx.compose.ui.unit.Dp)), [`width`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).width(androidx.compose.ui.unit.Dp)), [`height`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).height(androidx.compose.ui.unit.Dp)), and [`depth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).depth(androidx.compose.ui.unit.Dp))\ndeclare the preferred size of the content. To declare the exact size of the\ncontent, use [`requiredSize`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).requiredSize(androidx.compose.ui.unit.Dp)), [`requiredWidth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).requiredWidth(androidx.compose.ui.unit.Dp)),\n[`requiredHeight`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).requiredHeight(androidx.compose.ui.unit.Dp)), and [`requiredDepth`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).requiredDepth(androidx.compose.ui.unit.Dp)). These units must be specified\nin `dp`; to convert from meters to dp, use [`Meter.toDp()`](/reference/kotlin/androidx/xr/compose/unit/Meter#toDp()).\n\nPosition composables\n--------------------\n\n### `offset`\n\nThe [`offset`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).offset(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)) modifier moves the composable in 3D space along the `x`, `y`,\nand `z` axes. These units must be specified in `dp`; to convert from meters to\ndp, use [`Meter.toDp()`](/reference/kotlin/androidx/xr/compose/unit/Meter#toDp()).\n\n### `rotate`\n\nThe [`rotate`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).rotate(androidx.xr.runtime.math.Quaternion)) modifier rotates the given composable in space. You can\nspecify the direction and the amount of rotation in different ways:\n\n- Using pitch, yaw, and roll, which specify the rotation around the `x`, `y`, and `z` axes respectively,\n- Using an `axisAngle`, which is a `Vector3` representing the axis of rotation, and the amount of degrees it should be rotated around,\n- Using a `Quaternion` that represents the rotation.\n\nChange the appearance of composables\n------------------------------------\n\n### `alpha`\n\nThe [`alpha`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).alpha(kotlin.Float)) modifier sets the opacity of the element and its children,\nwhere `0f` represents fully transparent and `1.0f` represents completely opaque.\n| **Preview:** Currently, the `alpha` modifier only works on `SpatialPanel`.\n\n### `scale`\n\nThe [`scale`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).scale(kotlin.Float)) modifier scales the contents of the composible along the\nhorizontal, vertical, and depth axes.\n\nAdd behaviors to composables\n----------------------------\n\n### `resizable`\n\nWhen the [`resizable`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).resizable(kotlin.Boolean,androidx.xr.compose.unit.DpVolumeSize,androidx.xr.compose.unit.DpVolumeSize,kotlin.Boolean,kotlin.Function1)) modifier is enabled, draggable UI controls will be\nshown that allow the user to resize the element. This is similar to using\n[`ResizableComponent`](/reference/kotlin/androidx/xr/scenecore/ResizableComponent) on an `Entity`.\n\n\nYour browser doesn't support HTML video. Here is a\n[link to the video](/static/develop/xr/jetpack-xr-sdk/videos/resizablecomponent.mp4) instead.\n| **Preview:** Currently, the `resizable` modifier only works on `SpatialPanel`.\n\n### `movable`\n\nWhen the [`movable`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).movable(kotlin.Boolean,kotlin.Boolean,kotlin.Boolean,kotlin.Function1,kotlin.Function1,kotlin.Function1)) modifier is enabled, UI controls will be added to the\ncomponent which allow the user to move the element in 3D space. This is similar\nto using [`MovableComponent`](/reference/kotlin/androidx/xr/scenecore/MovableComponent) on an `Entity`.\n\n\nYour browser doesn't support HTML video. Here is a\n[link to the video](/static/develop/xr/jetpack-xr-sdk/videos/movablecomponent.mp4) instead.\n\nA `movable` layout node can optionally specify types of planes it should anchor\nto when it is moved. For example, to create a `SpatialPanel` that snaps to\ntables: \n\n SpatialPanel(\n modifier.movable(anchorPlaneSemantics = setOf(PlaneSemantic.TABLE))\n ) {\n // This panel snaps to available planes that are detected as a TABLE.\n }\n\nSnapping to planes requires the `android.permission.SCENE_UNDERSTANDING_COARSE`\n[runtime permission](/training/permissions/requesting) to be granted to your app.\n| **Preview:** Currently, the `movable` modifier only works on `SpatialPanel`.\n\nTesting and accessibility\n-------------------------\n\n### `semantics`\n\nThe [`semantics`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).semantics(kotlin.Function1)) modifier adds semantics to the layout node, for use in\ntesting and accessibility. See [Semantics in Jetpack Compose](/develop/ui/compose/accessibility/semantics) and\n[`SemanticsModifier`](/reference/kotlin/androidx/compose/ui/semantics/SemanticsModifier).\n\n### `testTag`\n\nThe [`testTag`](/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceModifier#(androidx.xr.compose.subspace.layout.SubspaceModifier).testTag(kotlin.String)) modifier is a shorthand for\n[`SemanticsPropertyReceiver.testTag`](/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyReceiver#(androidx.compose.ui.semantics.SemanticsPropertyReceiver).testTag()), which allows test frameworks to find\nthe element in tests."]]