SpatialAndroidViewPanel

Functions summary

Unit
@Composable
@SubspaceComposable
<T : View> SpatialAndroidViewPanel(
    factory: (Context) -> T,
    modifier: SubspaceModifier,
    update: (T) -> Unit,
    shape: SpatialShape,
    dragPolicy: DragPolicy?,
    resizePolicy: ResizePolicy?,
    interactionPolicy: InteractionPolicy?
)

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

Functions

SpatialAndroidViewPanel

@Composable
@SubspaceComposable
fun <T : View> SpatialAndroidViewPanel(
    factory: (Context) -> T,
    modifier: SubspaceModifier = SubspaceModifier,
    update: (T) -> Unit = {},
    shape: SpatialShape = SpatialPanelDefaults.shape,
    dragPolicy: DragPolicy? = null,
    resizePolicy: ResizePolicy? = null,
    interactionPolicy: InteractionPolicy? = null
): Unit

Creates a SpatialAndroidViewPanel 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 SpatialAndroidViewPanel 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. SpatialAndroidViewPanel 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.

dragPolicy: DragPolicy? = null

An optional DragPolicy that defines the motion behavior of the SpatialPanel. This can be either a MovePolicy for free movement or an AnchorPolicy for anchoring to real-world surfaces. If a policy is provided, draggable UI controls will be shown, allowing the user to manipulate the panel in 3D space. If null, no motion behavior is applied.

resizePolicy: ResizePolicy? = null

An optional ResizePolicy configuration object that resizing behavior of this SpatialPanel. The draggable UI controls will be shown that allow the user to resize the element in 3D space. If null, there is no resize behavior applied to the element.

interactionPolicy: InteractionPolicy? = null

An optional InteractionPolicy that can be set to detect 3D input events. Setting this will not intercept 2D input events and is intended to provide additional spatial input information.