Start native apps faster with the Composables CLI ->
Class

FollowBehavior

A FollowBehavior controls the motion of content as it is following another target, such as a user's head.

Source set: Android
@ExperimentalFollowingSubspaceApi
public sealed class FollowBehavior protected constructor()

A FollowBehavior controls the motion of content as it is following another target, such as a user's head. Currently the options include "soft", which gradually catches up to the target and "static", which does not continuously follow the target.

Companion Object

Properties

Source set: Android
public const val DEFAULT_SOFT_DURATION_MS: Int

The default duration, in milliseconds, for a soft follow animation.

Source set: Android
public const val MIN_SOFT_DURATION_MS: Int

The minimum allowable duration in milliseconds for a soft follow animation.

Source set: Android
public val Static: FollowBehavior

The content is placed once based on the target's initial pose and does not follow subsequent movements.

Source set: Android
public val Tight: FollowBehavior

The content follows the target as closely as possible.

Methods

Source set: Android
public fun Soft(
            @IntRange(from = MIN_SOFT_DURATION_MS.toLong())
            durationMs: Int = DEFAULT_SOFT_DURATION_MS
        ): FollowBehavior

Creates a behavior where the content smoothly animates to follow the target's movements.

This behavior is driven by a critically damped spring physics model, which uses exponential decay to smoothly decelerate the trailing entity as it approaches the target. The entity will accelerate to catch up and then decelerate without overshoot, simulating real-world physical inertia.

The use of this spring/exponential decay model is not optional, but the total duration of the motion can be configured via durationMs.

Parameters

durationMs Amount of milliseconds it takes for the content to catch up to the user. Default is DEFAULT_SOFT_DURATION_MS milliseconds. A value less than MIN_SOFT_DURATION_MS will be rounded up to MIN_SOFT_DURATION_MS to allow enough time to complete the content movement.

Returns

A FollowBehavior instance configured for soft following.
Source set: Android
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public fun ExponentialDecay(): FollowBehavior

Creates a behavior where the content animates to follow the target's movements using an exponential decay algorithm.

This behavior is driven by a first-order exponential decay model, matching the system's native HeadFollower implementation.

Returns

A FollowBehavior instance configured for exponential decay.

Last updated: