Start native apps faster with the Composables CLI ->
Class

AnchorPolicy

Represents the anchoring behavior of a spatial object.

Source set: Android
public class AnchorPolicy(
    public val isEnabled: Boolean = true,
    @Suppress("PrimitiveInCollection")
    public val anchorPlaneOrientations: Set<PlaneOrientation> = emptySet(),
    @Suppress("PrimitiveInCollection")
    public val anchorPlaneSemantics: Set<PlaneSemantic> = emptySet(),
) : DragPolicy()

Represents the anchoring behavior of a spatial object.

An AnchorPolicy object can be placed and re-anchored on detected surfaces in the environment. This class defines properties that control how anchoring behaves, such as whether it's enabled and what types of planes it can anchor to.

This functionality requires androidx.xr.runtime.Session.configure to be called with androidx.xr.runtime.PlaneTrackingMode.HORIZONTAL_AND_VERTICAL. This configuration requires that the SCENE_UNDERSTANDING_COARSE Android permission is granted. If not granted, the anchorable functionality will be disabled, and the element will behave as if the anchorable modifier was not applied.

Last updated: