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

androidx.compose.foundation.gestures.snapping

Interfaces

SnapLayoutInfoProvider

Provides information about the layout that is using a SnapFlingBehavior.

Cmn
SnapPositionInLayout

Describes the general positioning of a given snap item in its containing layout.

Cmn

Classes

SnapFlingBehavior

A FlingBehavior that performs snapping of items to a given position.

Cmn

Top-level functions summary

SnapLayoutInfoProvider
@ExperimentalFoundationApi
SnapLayoutInfoProvider(
    lazyGridState: LazyGridState,
    positionInLayout: SnapPositionInLayout
)

A SnapLayoutInfoProvider for LazyGrids.

Cmn
SnapLayoutInfoProvider
@ExperimentalFoundationApi
SnapLayoutInfoProvider(
    lazyListState: LazyListState,
    positionInLayout: SnapPositionInLayout
)

A SnapLayoutInfoProvider for LazyLists.

Cmn
FlingBehavior

Create and remember a FlingBehavior for decayed snapping in Lazy Lists.

Cmn
SnapFlingBehavior

Creates and remember a FlingBehavior that performs snapping.

Cmn

Top-level functions

SnapLayoutInfoProvider

@ExperimentalFoundationApi
fun SnapLayoutInfoProvider(
    lazyGridState: LazyGridState,
    positionInLayout: SnapPositionInLayout = SnapPositionInLayout.CenterToCenter
): SnapLayoutInfoProvider

A SnapLayoutInfoProvider for LazyGrids.

Parameters
lazyGridState: LazyGridState

The LazyGridState with information about the current state of the grid

positionInLayout: SnapPositionInLayout = SnapPositionInLayout.CenterToCenter

The desired positioning of the snapped item within the main layout. This position should be considered with regards to the start edge of the item and the placement within the viewport.

Returns
SnapLayoutInfoProvider

A SnapLayoutInfoProvider that can be used with SnapFlingBehavior

SnapLayoutInfoProvider

@ExperimentalFoundationApi
fun SnapLayoutInfoProvider(
    lazyListState: LazyListState,
    positionInLayout: SnapPositionInLayout = SnapPositionInLayout.CenterToCenter
): SnapLayoutInfoProvider

A SnapLayoutInfoProvider for LazyLists.

Parameters
lazyListState: LazyListState

The LazyListState with information about the current state of the list

positionInLayout: SnapPositionInLayout = SnapPositionInLayout.CenterToCenter

The desired positioning of the snapped item within the main layout. This position should be considered with regard to the start edge of the item and the placement within the viewport.

Returns
SnapLayoutInfoProvider

A SnapLayoutInfoProvider that can be used with SnapFlingBehavior

rememberSnapFlingBehavior

@ExperimentalFoundationApi
@Composable
fun rememberSnapFlingBehavior(lazyListState: LazyListState): FlingBehavior

Create and remember a FlingBehavior for decayed snapping in Lazy Lists. This will snap the item's center to the center of the viewport.

Parameters
lazyListState: LazyListState

The LazyListState from the LazyList where this FlingBehavior will be used.

rememberSnapFlingBehavior

@ExperimentalFoundationApi
@Composable
fun rememberSnapFlingBehavior(
    snapLayoutInfoProvider: SnapLayoutInfoProvider
): SnapFlingBehavior

Creates and remember a FlingBehavior that performs snapping.

Parameters
snapLayoutInfoProvider: SnapLayoutInfoProvider

The information about the layout that will do snapping