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

ScrollableStateKt

public final class ScrollableStateKt


Summary

Public methods

static final @NonNull ScrollableState
ScrollableState(
    @NonNull Function1<@NonNull Float, @NonNull Float> consumeScrollDelta
)

Default implementation of ScrollableState interface that contains necessary information about the ongoing fling and provides smooth scrolling capabilities.

static final @NonNull ScrollableState
@Composable
rememberScrollableState(
    @NonNull Function1<@NonNull Float, @NonNull Float> consumeScrollDelta
)

Create and remember the default implementation of ScrollableState interface that contains necessary information about the ongoing fling and provides smooth scrolling capabilities.

Public methods

ScrollableState

public static final @NonNull ScrollableState ScrollableState(
    @NonNull Function1<@NonNull Float, @NonNull Float> consumeScrollDelta
)

Default implementation of ScrollableState interface that contains necessary information about the ongoing fling and provides smooth scrolling capabilities.

This is the simplest way to set up a scrollable modifier. When constructing this ScrollableState, you must provide a consumeScrollDelta lambda, which will be invoked whenever scroll happens (by gesture input, by smooth scrolling, by flinging or nested scroll) with the delta in pixels. The amount of scrolling delta consumed must be returned from this lambda to ensure proper nested scrolling behaviour.

Parameters
@NonNull Function1<@NonNull Float, @NonNull Float> consumeScrollDelta

callback invoked when drag/fling/smooth scrolling occurs. The callback receives the delta in pixels. Callers should update their state in this lambda and return the amount of delta consumed

rememberScrollableState

@Composable
public static final @NonNull ScrollableState rememberScrollableState(
    @NonNull Function1<@NonNull Float, @NonNull Float> consumeScrollDelta
)

Create and remember the default implementation of ScrollableState interface that contains necessary information about the ongoing fling and provides smooth scrolling capabilities.

This is the simplest way to set up a scrollable modifier. When constructing this ScrollableState, you must provide a consumeScrollDelta lambda, which will be invoked whenever scroll happens (by gesture input, by smooth scrolling, by flinging or nested scroll) with the delta in pixels. The amount of scrolling delta consumed must be returned from this lambda to ensure proper nested scrolling behaviour.

Parameters
@NonNull Function1<@NonNull Float, @NonNull Float> consumeScrollDelta

callback invoked when drag/fling/smooth scrolling occurs. The callback receives the delta in pixels. Callers should update their state in this lambda and return the amount of delta consumed