Start native apps faster with the Composables CLI ->
Interface

MovePolicy

Defines the behavior and configuration for movement applied by the movable modifier.

Source set: Android
public sealed interface MovePolicy

Defines the behavior and configuration for movement applied by the movable modifier.

Members

Companion

Source set: Android
public companion object

Properties

Default

Source set: Android
public val Default: MovePolicy = system()

The default system-handled move policy.

Functions

system

Source set: Android
public fun system(
            scaleWithDistance: Boolean = true,
            onMove: ((SpatialMoveEvent) -> Unit)? = null,
        ): MovePolicy

A policy that delegates the pose transformation entirely to the system.

The system intercepts spatial input events, calculates the resulting Pose and scale, and automatically applies these transformations to the element's layout. This is the standard behavior where a 1:1 transformation is desired, and custom gesture handling or manual state management is not required. This policy will have a better overall performance than the custom policy.

Parameters

scaleWithDistance true if this composable should scale in size when moved in depth. When enabled, the subspace element will grow if pushed away from the user or shrink when pulled toward the user in order to maintain the interactability and legibility of the panel. Scaling with distance respects other transformations applied to this layout.
onMove Optional observer callback invoked during the manipulation. Since the system automatically applies the move, this callback is strictly for monitoring changes and should not control the position. The onMove callback values can be used to position other sibling composables with the offset modifier. This callback reports a SpatialMoveEvent which will contain a Pose. The Pose contained in this event is the sum of all previous events in the move gesture.

custom

Source set: Android
public fun custom(
            scaleWithDistance: Boolean = false,
            onMove: ((SpatialMoveEvent) -> Unit),
        ): MovePolicy

A policy that accepts move events and reports the calculated pose updates via a callback, without automatically applying a resulting transformation.

This policy enables custom behavior for movement of the content. The system calculates the target Pose based on input, but does not automatically apply it to the associated layout. The developer is responsible for consuming the onMove event and applying the result (e.g., by updating a state backed by SubspaceModifier.offset). Using this policy has higher latency than system.

Parameters

scaleWithDistance true if this composable should scale in size when moved in depth. When enabled, the subspace element will grow if pushed away from the user or shrink when pulled toward the user in order to maintain the interactability and legibility of the panel. Scaling with distance respects other transformations applied to this layout.
onMove callback invoked continuously during the interaction that receives a SpatialMoveEvent containing the calculated target pose, scale, and size. The pose contained in this event is the sum of all previous events in the move gesture. The receiver MUST use this data to update the element's external state to reflect movement.

anchor

Source set: Android
public fun anchor(
            anchorPlaneOrientations: Set<PlaneOrientation> = emptySet(),
            anchorPlaneSemantics: Set<PlaneSemantic> = emptySet(),
            onMove: ((SpatialMoveEvent) -> Unit)? = null,
        ): MovePolicy

A policy that enables anchoring the movable element to detected real-world planes.

Using this policy allows the user to snap the subspace element to physical surfaces (like tables or walls) that match the provided orientations and semantics. If no specific orientations or semantics are provided (i.e., the sets are empty), the element is permitted to anchor to any detected plane.

Note: Once a composable is anchored to an external plane using this policy, it is reparented outside the normal Compose hierarchy. As a result, conventional layout pose calculations and pose-based modifiers (such as rotate or gravityAligned) are not currently compatible with the anchored composable.

Parameters

anchorPlaneOrientations The set of PlaneOrientations (e.g., Horizontal, Vertical) that the element is permitted to anchor to. Defaults to an empty set, which allows all orientations.
anchorPlaneSemantics The set of PlaneSemantics (e.g., Wall, Floor, Table) that the element is permitted to anchor to. Defaults to an empty set, which allows all semantics.
onMove Optional observer callback invoked during the manipulation to monitor the movement and anchoring events.