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

RelocationModifier


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 functions

Rect
computeDestination(source: Rect, layoutCoordinates: LayoutCoordinates)

Compute the destination given the source rectangle and current bounds.

Cmn
suspend Unit
performRelocation(source: Rect, destination: Rect)

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

Cmn

Inherited functions

From androidx.compose.ui.Modifier
open infix Modifier
then(other: Modifier)

Concatenates this modifier with another.

Cmn
From androidx.compose.ui.Modifier.Element
open Boolean
all(predicate: (Modifier.Element) -> Boolean)

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

Cmn
open Boolean
any(predicate: (Modifier.Element) -> Boolean)

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

Cmn
open R
<R : Any?> foldIn(initial: R, operation: (Modifier.Element, R) -> R)

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

Cmn
open R
<R : Any?> foldOut(initial: R, operation: (Modifier.Element, R) -> R)

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

Cmn

Public functions

computeDestination

fun computeDestination(source: Rect, layoutCoordinates: LayoutCoordinates): Rect

Compute the destination given the source rectangle and current bounds.

Parameters
source: Rect

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

layoutCoordinates: LayoutCoordinates

The layoutCoordinates associated with this modifier.

Returns
Rect

the destination rectangle.

performRelocation

suspend fun performRelocation(source: Rect, destination: Rect): Unit

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).