androidx.xr.compose.subspace

Interfaces

SpatialBoxScope

Scope for the children of SpatialBox.

SpatialColumnScope

Scope for customizing the layout of children within a SpatialColumn.

SpatialExternalSurfaceScope

SpatialExternalSurfaceScope is a scoped environment that provides the Surface associated with a SpatialExternalSurface

SpatialRowScope

Scope for customizing the layout of children within a SpatialRow.

Classes

StereoMode

Mode for SpatialExternalSurface display.

Objects

SpatialCurvedRowDefaults

Contains the default values used by SpatialCurvedRow.

SpatialPanelDefaults

Contains default values used by spatial panels.

Annotations

SubspaceComposable

Marks a composable function or other code element as intended for use within the context of SubspaceComposable functions.

Top-level functions summary

Unit

Creates a SpatialPanel backed by the main Window content.

Unit
@Composable
@SubspaceComposable
SpatialBox(
    modifier: SubspaceModifier,
    alignment: SpatialAlignment,
    propagateMinConstraints: Boolean,
    content: @Composable @SubspaceComposable SpatialBoxScope.() -> Unit
)

A layout composable that sizes itself to fit its content, subject to incoming constraints.

Unit

A layout composable that arranges its children in a vertical sequence.

Unit
@Composable
@SubspaceComposable
SpatialCurvedRow(
    modifier: SubspaceModifier,
    alignment: SpatialAlignment,
    curveRadius: Dp,
    content: @Composable @SubspaceComposable SpatialRowScope.() -> Unit
)

A layout composable that arranges its children in a curved horizontal sequence.

Unit

A Composable that creates and owns an Android Surface into which the application can render stereo image content.

Unit

A composable that represents an empty space layout.

Unit
@Composable
@SubspaceComposable
SpatialPanel(
    intent: Intent,
    modifier: SubspaceModifier,
    shape: SpatialShape
)

Creates a SpatialPanel and launches an Activity within it.

Unit
@Composable
@SubspaceComposable
SpatialPanel(
    modifier: SubspaceModifier,
    shape: SpatialShape,
    content: @Composable @UiComposable () -> Unit
)

Creates a SpatialPanel representing a 2D plane in 3D space in which an application can fill content.

Unit

This function is deprecated. Use SpatialPanel(factory, modifier, update, shape) instead.

Unit
@Composable
@SubspaceComposable
<T : View> SpatialPanel(
    factory: (Context) -> T,
    modifier: SubspaceModifier,
    update: (T) -> Unit,
    shape: SpatialShape
)

Creates a SpatialPanel representing a 2D plane in 3D space where an Android View will be hosted.

Unit

A layout composable that arranges its children in a horizontal sequence.

Unit
@Composable
@SubspaceComposable
Volume(modifier: SubspaceModifier, onVolumeEntity: (Entity) -> Unit)

A composable that represents a 3D volume of space within which an application can fill content.

Top-level functions

@Composable
@SubspaceComposable
fun MainPanel(
    modifier: SubspaceModifier = SubspaceModifier,
    shape: SpatialShape = SpatialPanelDefaults.shape
): Unit

Creates a SpatialPanel backed by the main Window content.

This panel requires the following specific configuration in the Android Manifest for proper sizing/resizing behavior:

<activity
android
:configChanges="orientation|screenSize|screenLayout|smallestScreenSize>
<!--suppress AndroidElementNotAllowed -->
<layout android:defaultWidth="
50dp" android:defaultHeight="50dp" android:minHeight="50dp"
android:minWidth="
50dp"/>
</activity>
Parameters
modifier: SubspaceModifier = SubspaceModifier

SubspaceModifier to apply to the MainPanel.

shape: SpatialShape = SpatialPanelDefaults.shape

The shape of this Spatial Panel.

SpatialBox

@Composable
@SubspaceComposable
fun SpatialBox(
    modifier: SubspaceModifier = SubspaceModifier,
    alignment: SpatialAlignment = SpatialAlignment.Center,
    propagateMinConstraints: Boolean = false,
    content: @Composable @SubspaceComposable SpatialBoxScope.() -> Unit
): Unit

A layout composable that sizes itself to fit its content, subject to incoming constraints.

A layout composable with content. The SpatialBox will size itself to fit the content, subject to the incoming constraints. When children are smaller than the parent, by default they will be positioned inside the SpatialBox according to the alignment. For individually specifying the alignments of the children layouts, use the SpatialBoxScope.align modifier. By default, the content will be measured without the SpatialBox's incoming min constraints. If propagateMinConstraints is set to true, the min size set on the SpatialBox will also be applied to the content.

Note: If the content has multiple children, they might overlap depending on their positioning.

Parameters
modifier: SubspaceModifier = SubspaceModifier

The modifier to be applied to the layout.

alignment: SpatialAlignment = SpatialAlignment.Center

The default alignment of children within the SpatialBox.

propagateMinConstraints: Boolean = false

Whether the incoming min constraints should be passed to content.

content: @Composable @SubspaceComposable SpatialBoxScope.() -> Unit

The content of the SpatialBox.

SpatialColumn

@Composable
@SubspaceComposable
fun SpatialColumn(
    modifier: SubspaceModifier = SubspaceModifier,
    alignment: SpatialAlignment = SpatialAlignment.Center,
    content: @Composable @SubspaceComposable SpatialColumnScope.() -> Unit
): Unit

A layout composable that arranges its children in a vertical sequence.

For arranging children horizontally, see SpatialRow.

Parameters
modifier: SubspaceModifier = SubspaceModifier

Modifiers to apply to the layout.

alignment: SpatialAlignment = SpatialAlignment.Center

The default alignment for child elements within the column.

content: @Composable @SubspaceComposable SpatialColumnScope.() -> Unit

The composable content to be laid out vertically.

SpatialCurvedRow

@Composable
@SubspaceComposable
fun SpatialCurvedRow(
    modifier: SubspaceModifier = SubspaceModifier,
    alignment: SpatialAlignment = SpatialAlignment.Center,
    curveRadius: Dp = SpatialCurvedRowDefaults.curveRadius,
    content: @Composable @SubspaceComposable SpatialRowScope.() -> Unit
): Unit

A layout composable that arranges its children in a curved horizontal sequence.

Parameters
modifier: SubspaceModifier = SubspaceModifier

Appearance modifiers to apply to this Composable.

alignment: SpatialAlignment = SpatialAlignment.Center

The default alignment for child elements within the row.

curveRadius: Dp = SpatialCurvedRowDefaults.curveRadius

Defines the curve of the row by specifying its radius in Dp. A larger radius creates a gentler curve (less curvature), while a smaller positive radius results in a sharper curve (more curvature). Using Dp.Infinity or a non-positive value (zero or negative) makes the row straight. When curved, row items are angled to follow the curve's path. This value is the radial distance in the polar coordinate system.

content: @Composable @SubspaceComposable SpatialRowScope.() -> Unit

The composable content to be laid out horizontally in the row.

SpatialExternalSurface

@Composable
@SubspaceComposable
fun SpatialExternalSurface(
    stereoMode: StereoMode,
    modifier: SubspaceModifier = SubspaceModifier,
    featheringEffect: SpatialFeatheringEffect = SpatialSmoothFeatheringEffect(ZeroFeatheringSize),
    content: @Composable @SubspaceComposable SpatialExternalSurfaceScope.() -> Unit
): Unit

A Composable that creates and owns an Android Surface into which the application can render stereo image content. This Surface is then texture mapped to the canvas, and if a stereoscopic StereoMode is specified, then the User will see left and right eye content mapped to the appropriate display. Width and height will default to 400 pixels if it is not specified using size modifiers.

Note that this Surface does not capture input events. It is also not currently possible to synchronize StereoMode changes with application rendering or video decoding. This composable currently cannot render in front of other panels, so movable modifier usage is not recommended if there are other panels in the layout, aside from the content block of this Composable.

Parameters
stereoMode: StereoMode

The StereoMode which describes how parts of the surface are displayed to the user's eyes. This will affect how the content is interpreted and displayed on the surface.

modifier: SubspaceModifier = SubspaceModifier

SubspaceModifiers to apply to the SpatialSurfacePanel.

featheringEffect: SpatialFeatheringEffect = SpatialSmoothFeatheringEffect(ZeroFeatheringSize)

A SpatialFeatheringEffect to apply to to canvas of SpatialExternalSurfaceScope.surface.

content: @Composable @SubspaceComposable SpatialExternalSurfaceScope.() -> Unit

Content block where the surface can be accessed using SpatialExternalSurfaceScope.surface. Composable content will be rendered over the Surface canvas. If using StereoMode.SideBySide or StereoMode.TopBottom, it is recommended to offset Composable content far enough to avoid depth perception issues.

SpatialLayoutSpacer

@Composable
@SubspaceComposable
fun SpatialLayoutSpacer(modifier: SubspaceModifier = SubspaceModifier): Unit

A composable that represents an empty space layout. Its size can be controlled using modifiers like SubspaceModifier.width, SubspaceModifier.height, etc.

Parameters
modifier: SubspaceModifier = SubspaceModifier

Modifiers to apply to the spacer.

SpatialPanel

@Composable
@SubspaceComposable
fun SpatialPanel(
    intent: Intent,
    modifier: SubspaceModifier = SubspaceModifier,
    shape: SpatialShape = SpatialPanelDefaults.shape
): Unit

Creates a SpatialPanel and launches an Activity within it.

Parameters
intent: Intent

The intent of an Activity to launch within this panel.

modifier: SubspaceModifier = SubspaceModifier

SubspaceModifiers to apply to the SpatialPanel.

shape: SpatialShape = SpatialPanelDefaults.shape

The shape of this Spatial Panel.

SpatialPanel

@Composable
@SubspaceComposable
fun SpatialPanel(
    modifier: SubspaceModifier = SubspaceModifier,
    shape: SpatialShape = SpatialPanelDefaults.shape,
    content: @Composable @UiComposable () -> Unit
): Unit

Creates a SpatialPanel representing a 2D plane in 3D space in which an application can fill content.

Parameters
modifier: SubspaceModifier = SubspaceModifier

SubspaceModifiers to apply to the SpatialPanel.

shape: SpatialShape = SpatialPanelDefaults.shape

The shape of this Spatial Panel.

content: @Composable @UiComposable () -> Unit

The composable content to render within the SpatialPanel.

SpatialPanel

@Composable
@SubspaceComposable
fun SpatialPanel(
    view: View,
    modifier: SubspaceModifier = SubspaceModifier,
    shape: SpatialShape = SpatialPanelDefaults.shape
): Unit

Creates a SpatialPanel representing a 2D plane in 3D space in which an application can fill content.

Parameters
view: View

Content view to be displayed within the SpatialPanel.

modifier: SubspaceModifier = SubspaceModifier

SubspaceModifiers to apply to the SpatialPanel.

shape: SpatialShape = SpatialPanelDefaults.shape

The shape of this Spatial Panel.

SpatialPanel

@Composable
@SubspaceComposable
fun <T : View> SpatialPanel(
    factory: (Context) -> T,
    modifier: SubspaceModifier = SubspaceModifier,
    update: (T) -> Unit = {},
    shape: SpatialShape = SpatialPanelDefaults.shape
): Unit

Creates a SpatialPanel representing a 2D plane in 3D space where an Android View will be hosted.

The presented View is obtained from factory. The factory block will be called exactly once to obtain the View being composed into this panel, and it is also guaranteed to be executed on the main thread. Therefore, in addition to creating the View, the factory block can also be used to perform one-off initializations and View constant properties' setting. The factory inside of the constructor is used to avoid the need to pass the context to the factory. There is one View for every SpatialPanel instance and it is reused across recompositions. This View is shown effectively in isolation and does not interact directly with the other composable's that surround it. The update block can run multiple times (on the UI thread as well) due to recomposition, and it is the right place to set the new properties. Note that the block will also run once right after the factory block completes. SpatialPanel will clip the view content to fit the panel.

Parameters
<T : View>

The type of the Android View to be created.

factory: (Context) -> T

A lambda that creates an instance of the Android View T.

modifier: SubspaceModifier = SubspaceModifier

SubspaceModifiers to apply to the SpatialPanel.

update: (T) -> Unit = {}

A lambda that allows updating the created Android View T.

shape: SpatialShape = SpatialPanelDefaults.shape

The shape of this Spatial Panel.

SpatialRow

@Composable
@SubspaceComposable
fun SpatialRow(
    modifier: SubspaceModifier = SubspaceModifier,
    alignment: SpatialAlignment = SpatialAlignment.Center,
    content: @Composable @SubspaceComposable SpatialRowScope.() -> Unit
): Unit

A layout composable that arranges its children in a horizontal sequence. For arranging children vertically, see SpatialColumn.

Parameters
modifier: SubspaceModifier = SubspaceModifier

Appearance modifiers to apply to this Composable.

alignment: SpatialAlignment = SpatialAlignment.Center

The default alignment for child elements within the row.

content: @Composable @SubspaceComposable SpatialRowScope.() -> Unit

The composable content to be laid out horizontally in the row.

@Composable
@SubspaceComposable
fun Volume(
    modifier: SubspaceModifier = SubspaceModifier,
    onVolumeEntity: (Entity) -> Unit
): Unit

A composable that represents a 3D volume of space within which an application can fill content.

This composable provides a Entity through the onVolumeEntity lambda, allowing the caller to attach child Jetpack XR Entities to it.

Parameters
modifier: SubspaceModifier = SubspaceModifier

SubspaceModifiers to apply to the Volume.

onVolumeEntity: (Entity) -> Unit

A lambda function that will be invoked when the Entity becomes available.