{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

RelocationModifier

@ExperimentalComposeUiApi
public interface RelocationModifier extends Modifier.Element


A modifier that can be used to respond to relocation requests to relocate an item on screen.

When a child calls RelocationRequester.bringIntoView, the framework calls computeDestination where you can take the source bounds and compute the destination rectangle for the child. Relocation Modifiers higher up the hierarchy will receive this destination as their source rect. Finally after all relocation modifiers have a chance to compute their destinations, the framework calls performRelocation(source, destination) which performs the actual relocation (scrolling).

See also
RelocationRequester

Summary

Public methods

abstract @NonNull Rect
computeDestination(
    @NonNull Rect source,
    @NonNull LayoutCoordinates layoutCoordinates
)

Compute the destination given the source rectangle and current bounds.

abstract void
performRelocation(@NonNull Rect source, @NonNull Rect destination)

Using the source and destination bounds, perform a relocation operation that moves the source rect to the destination location.

Inherited methods

From androidx.compose.ui.Modifier
default @NonNull Modifier

Concatenates this modifier with another.

From androidx.compose.ui.Modifier.Element
default boolean
all(
    @NonNull Function1<@NonNull Modifier.Element, @NonNull Boolean> predicate
)

Returns true if predicate returns true for all Elements in this Modifier or if this Modifier contains no Elements.

default boolean
any(
    @NonNull Function1<@NonNull Modifier.Element, @NonNull Boolean> predicate
)

Returns true if predicate returns true for any Element in this Modifier.

default @NonNull R
<R extends Object> foldIn(
    @NonNull R initial,
    @NonNull Function2<@NonNull R, @NonNull Modifier.Element, @NonNull R> operation
)

Accumulates a value starting with initial and applying operation to the current value and each element from outside in.

default @NonNull R
<R extends Object> foldOut(
    @NonNull R initial,
    @NonNull Function2<@NonNull Modifier.Element, @NonNull R, @NonNull R> operation
)

Accumulates a value starting with initial and applying operation to the current value and each element from inside out.

Public methods

computeDestination

abstract @NonNull Rect computeDestination(
    @NonNull Rect source,
    @NonNull LayoutCoordinates layoutCoordinates
)

Compute the destination given the source rectangle and current bounds.

Parameters
@NonNull Rect source

The bounding box of the item that sent the request to be brought into view.

@NonNull LayoutCoordinates layoutCoordinates

The layoutCoordinates associated with this modifier.

Returns
@NonNull Rect

the destination rectangle.

performRelocation

abstract void performRelocation(@NonNull Rect source, @NonNull Rect destination)

Using the source and destination bounds, perform a relocation operation that moves the source rect to the destination location. (This is usually achieved by scrolling).