androidx.xr.compose.spatial

Interfaces

OrbiterEdge

An enum that represents the edges of a view where an orbiter can be placed.

Classes

EdgeOffset

Represents the offset of an orbiter from the main panel.

OrbiterEdge.Horizontal
OrbiterEdge.Vertical

Represents vertical edges (start or end).

OrbiterOffsetType

Represents the type of offset used for positioning an orbiter.

OrbiterSettings

Settings for an Orbiter.

SpatialDialogProperties

Properties for configuring a SpatialDialog.

SpatialElevationLevel

Represents the resting elevation level for spatial elements.

SpatialPopupProperties

SpatialPopup properties.

Objects

OrbiterDefaults

Contains default values used by Orbiters.

Top-level functions summary

Unit
@Composable
Orbiter(
    position: OrbiterEdge.Horizontal,
    offset: Dp,
    alignment: Alignment.Horizontal,
    settings: OrbiterSettings,
    shape: SpatialShape,
    content: @Composable () -> Unit
)

A composable that creates an orbiter along the top or bottom edges of a view.

Unit
@Composable
Orbiter(
    position: OrbiterEdge.Horizontal,
    offset: EdgeOffset,
    alignment: Alignment.Horizontal,
    settings: OrbiterSettings,
    shape: SpatialShape,
    content: @Composable () -> Unit
)

A composable that creates an orbiter along the top or bottom edges of a view.

Unit
@Composable
Orbiter(
    position: OrbiterEdge.Vertical,
    offset: Dp,
    alignment: Alignment.Vertical,
    settings: OrbiterSettings,
    shape: SpatialShape,
    content: @Composable () -> Unit
)

A composable that creates an orbiter along the start or end edges of a view.

Unit
@Composable
Orbiter(
    position: OrbiterEdge.Vertical,
    offset: EdgeOffset,
    alignment: Alignment.Vertical,
    settings: OrbiterSettings,
    shape: SpatialShape,
    content: @Composable () -> Unit
)

A composable that creates an orbiter along the start or end edges of a view.

Unit
@Composable
SpatialDialog(
    onDismissRequest: () -> Unit,
    properties: SpatialDialogProperties,
    content: @Composable () -> Unit
)

SpatialDialog is a dialog that is elevated above the activity.

Unit
@Composable
SpatialElevation(
    spatialElevationLevel: SpatialElevationLevel,
    content: @Composable () -> Unit
)

Composable that creates a panel in 3D space when spatialization is enabled.

Unit
@Composable
SpatialPopup(
    spatialElevationLevel: SpatialElevationLevel,
    content: @Composable (onGloballyPositioned: (LayoutCoordinates) -> Unit) -> Unit
)

Opens a popup with the given content.

Unit
@Composable
SpatialPopup(
    alignment: Alignment,
    offset: IntOffset,
    onDismissRequest: (() -> Unit)?,
    properties: SpatialPopupProperties,
    content: @Composable () -> Unit
)

A composable that creates a panel in 3D space to hoist Popup based composables.

Unit

Create a 3D area that the app can render spatial content into.

Top-level functions

@Composable
fun Orbiter(
    position: OrbiterEdge.Horizontal,
    offset: Dp = 0.dp,
    alignment: Alignment.Horizontal = Alignment.CenterHorizontally,
    settings: OrbiterSettings = OrbiterDefaults.orbiterSettings,
    shape: SpatialShape = OrbiterDefaults.shape,
    content: @Composable () -> Unit
): Unit

A composable that creates an orbiter along the top or bottom edges of a view.

Parameters
position: OrbiterEdge.Horizontal

The edge of the orbiter. Use OrbiterEdge.Top or OrbiterEdge.Bottom.

offset: Dp = 0.dp

The offset of the orbiter based on the outer edge of the orbiter.

alignment: Alignment.Horizontal = Alignment.CenterHorizontally

The alignment of the orbiter. Use Alignment.CenterHorizontally or Alignment.Start or Alignment.End.

settings: OrbiterSettings = OrbiterDefaults.orbiterSettings

The settings for the orbiter.

shape: SpatialShape = OrbiterDefaults.shape

The shape of this Orbiter when it is rendered in 3D space.

content: @Composable () -> Unit

The content of the orbiter.

Example:

Orbiter(position = OrbiterEdge.Top, offset = 10.dp) {
Text("This is a top edge Orbiter")
}
@Composable
fun Orbiter(
    position: OrbiterEdge.Horizontal,
    offset: EdgeOffset,
    alignment: Alignment.Horizontal = Alignment.CenterHorizontally,
    settings: OrbiterSettings = OrbiterDefaults.orbiterSettings,
    shape: SpatialShape = OrbiterDefaults.shape,
    content: @Composable () -> Unit
): Unit

A composable that creates an orbiter along the top or bottom edges of a view.

Parameters
position: OrbiterEdge.Horizontal

The edge of the orbiter. Use OrbiterEdge.Top or OrbiterEdge.Bottom.

offset: EdgeOffset

The offset of the orbiter based on the inner or outer edge of the orbiter. Use EdgeOffset.outer to create an EdgeOffset aligned to the outer edge of the orbiter or innerEdge or EdgeOffset.overlap to create an EdgeOffset aligned to the inner edge of the orbiter.

alignment: Alignment.Horizontal = Alignment.CenterHorizontally

The alignment of the orbiter. Use Alignment.CenterHorizontally or Alignment.Start or Alignment.End.

settings: OrbiterSettings = OrbiterDefaults.orbiterSettings

The settings for the orbiter.

shape: SpatialShape = OrbiterDefaults.shape

The shape of this Orbiter when it is rendered in 3D space.

content: @Composable () -> Unit

The content of the orbiter.

Example:

Orbiter(position = OrbiterEdge.Top, offset = outer(10.dp)) {
Text("This is a top edge Orbiter")
}
@Composable
fun Orbiter(
    position: OrbiterEdge.Vertical,
    offset: Dp = 0.dp,
    alignment: Alignment.Vertical = Alignment.CenterVertically,
    settings: OrbiterSettings = OrbiterDefaults.orbiterSettings,
    shape: SpatialShape = OrbiterDefaults.shape,
    content: @Composable () -> Unit
): Unit

A composable that creates an orbiter along the start or end edges of a view.

Parameters
position: OrbiterEdge.Vertical

The edge of the orbiter. Use OrbiterEdge.Start or OrbiterEdge.End.

offset: Dp = 0.dp

The offset of the orbiter based on the outer edge of the orbiter.

alignment: Alignment.Vertical = Alignment.CenterVertically

The alignment of the orbiter. Use Alignment.CenterVertically or Alignment.Top or Alignment.Bottom.

settings: OrbiterSettings = OrbiterDefaults.orbiterSettings

The settings for the orbiter.

shape: SpatialShape = OrbiterDefaults.shape

The shape of this Orbiter when it is rendered in 3D space.

content: @Composable () -> Unit

The content of the orbiter.

Example:

Orbiter(position = OrbiterEdge.Start, offset = 10.dp) {
Text("This is a start edge Orbiter")
}
@Composable
fun Orbiter(
    position: OrbiterEdge.Vertical,
    offset: EdgeOffset,
    alignment: Alignment.Vertical = Alignment.CenterVertically,
    settings: OrbiterSettings = OrbiterDefaults.orbiterSettings,
    shape: SpatialShape = OrbiterDefaults.shape,
    content: @Composable () -> Unit
): Unit

A composable that creates an orbiter along the start or end edges of a view.

Parameters
position: OrbiterEdge.Vertical

The edge of the orbiter. Use OrbiterEdge.Start or OrbiterEdge.End.

offset: EdgeOffset

The offset of the orbiter based on the inner or outer edge of the orbiter. Use EdgeOffset.outer to create an EdgeOffset aligned to the outer edge of the orbiter or innerEdge or EdgeOffset.overlap to create an EdgeOffset aligned to the inner edge of the orbiter.

alignment: Alignment.Vertical = Alignment.CenterVertically

The alignment of the orbiter. Use Alignment.CenterVertically or Alignment.Top or Alignment.Bottom.

settings: OrbiterSettings = OrbiterDefaults.orbiterSettings

The settings for the orbiter.

shape: SpatialShape = OrbiterDefaults.shape

The shape of this Orbiter when it is rendered in 3D space.

content: @Composable () -> Unit

The content of the orbiter.

Example:

Orbiter(position = OrbiterEdge.Start, offset = outer(10.dp)) {
Text("This is a start edge Orbiter")
}

SpatialDialog

@Composable
fun SpatialDialog(
    onDismissRequest: () -> Unit,
    properties: SpatialDialogProperties = SpatialDialogProperties(),
    content: @Composable () -> Unit
): Unit

SpatialDialog is a dialog that is elevated above the activity.

Parameters
onDismissRequest: () -> Unit

a callback to be invoked when the dialog should be dismissed.

properties: SpatialDialogProperties = SpatialDialogProperties()

the dialog properties.

content: @Composable () -> Unit

the content of the dialog.

SpatialElevation

@Composable
fun SpatialElevation(
    spatialElevationLevel: SpatialElevationLevel = SpatialElevationLevel.Level0,
    content: @Composable () -> Unit
): Unit

Composable that creates a panel in 3D space when spatialization is enabled.

SpatialElevation elevates content in-place. It uses the source position and constraints to determine the size and placement of the elevated panel while reserving space for the original element within the layout.

In non-spatial environments, the content is rendered normally without elevation.

Parameters
spatialElevationLevel: SpatialElevationLevel = SpatialElevationLevel.Level0

the desired elevation level for the panel in spatial environments.

content: @Composable () -> Unit

the composable content to be displayed within the elevated panel.

SpatialPopup

@Composable
fun SpatialPopup(
    spatialElevationLevel: SpatialElevationLevel = SpatialElevationLevel.Level0,
    content: @Composable (onGloballyPositioned: (LayoutCoordinates) -> Unit) -> Unit
): Unit

Opens a popup with the given content.

Parameters
spatialElevationLevel: SpatialElevationLevel = SpatialElevationLevel.Level0

the resting elevation level of the popup.

content: @Composable (onGloballyPositioned: (LayoutCoordinates) -> Unit) -> Unit

the composable content to be displayed within the popup, along with a callback which is explicitly to be used for the onGloballyPositioned modifier of the Popup composable.

SpatialPopup

@Composable
fun SpatialPopup(
    alignment: Alignment = Alignment.TopStart,
    offset: IntOffset = IntOffset(0, 0),
    onDismissRequest: (() -> Unit)? = null,
    properties: SpatialPopupProperties = SpatialPopupProperties(),
    content: @Composable () -> Unit
): Unit

A composable that creates a panel in 3D space to hoist Popup based composables.

Parameters
alignment: Alignment = Alignment.TopStart

the alignment of the popup relative to its parent.

offset: IntOffset = IntOffset(0, 0)

An offset from the original aligned position of the popup. Offset respects the Ltr/Rtl context, thus in Ltr it will be added to the original aligned position and in Rtl it will be subtracted from it.

onDismissRequest: (() -> Unit)? = null

callback invoked when the user requests to dismiss the popup (e.g., by clicking outside).

properties: SpatialPopupProperties = SpatialPopupProperties()

PopupProperties configuration properties for further customization of this popup's behavior.

content: @Composable () -> Unit

the composable content to be displayed within the popup.

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

Create a 3D area that the app can render spatial content into.

If this is the topmost Subspace in the compose hierarchy then this will expand to fill all of the available space and will not be bound by its containing window.

If this is nested within another Subspace then it will lay out its content in the X and Y directions according to the layout logic of its parent in 2D space. It will be constrained in the Z direction according to the constraints imposed by its containing Subspace.

This is a no-op and does not render anything in non-XR environments (i.e. Phone and Tablet).

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

The 3D content to render within this Subspace.