androidx.compose.foundation.gestures
ScrollableState
Interface · from org.jetbrains.compose.foundation:foundation:1.12.2
No hand-written docs yet.
An object representing something that can be scrolled. This interface is implemented by states of scrollable containers such as androidx.compose.foundation.lazy.LazyListState or androidx.compose.foundation.ScrollState in order to provide low-level scrolling control via scroll, as well as allowing for higher-level scrolling functions like animateScrollBy to be implemented as extension functions on ScrollableState.
interface ScrollableState
Kinds of ScrollableState
Anywhere a ScrollableState is expected, you can pass any of these.
CarouselStateLazyGridStatefoundationLazyListStatefoundationLazyStaggeredGridStatefoundationPagerStatefoundationScrollStatefoundation
How to get one
Create it
ScrollableState(consumeScrollDelta: (Float) -> Float)
Or create one of the kinds listed above.
Used by
Parameters that take a ScrollableState.
scrollable(state)scrollableArea(state)TopAppBarDefaults.enterAlwaysScrollBehavior(scrollableState)TopAppBarDefaults.pinnedScrollBehavior(scrollableState)
Properties
isScrollInProgress
val isScrollInProgress: Boolean
Whether this ScrollableState is currently scrolling by gesture, fling or programmatically or not.
canScrollForward
val canScrollForward: Boolean
Whether this ScrollableState can scroll forward (consume a positive delta). This is typically false if the scroll position is equal to its maximum value, and true otherwise.
canScrollBackward
val canScrollBackward: Boolean
Whether this ScrollableState can scroll backward (consume a negative delta). This is typically false if the scroll position is equal to its minimum value, and true otherwise.
lastScrolledForward
val lastScrolledForward: Boolean
The value of this property is true under the following scenarios, otherwise it's false. - This ScrollableState is currently scrolling forward. - This ScrollableState was scrolling forward in its last scroll action.
lastScrolledBackward
val lastScrolledBackward: Boolean
The value of this property is true under the following scenarios, otherwise it's false. - This ScrollableState is currently scrolling backward. - This ScrollableState was scrolling backward in its last scroll action.
scrollIndicatorStateSince 1.10
val scrollIndicatorState: ScrollIndicatorState?
ScrollIndicatorState used for drawing a scroll indicator (e.g., a scrollbar).
Functions
scroll
fun scroll(
scrollPriority: MutatePriority = MutatePriority.Default,
block: suspend ScrollScope.() -> Unit,
)
Call this function to take control of scrolling and gain the ability to send scroll events via ScrollScope.scrollBy. All actions that change the logical scroll position must be performed within a scroll block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced.
dispatchRawDelta
fun dispatchRawDelta(delta: Float): Float
Dispatch scroll delta in pixels avoiding all scroll related mechanisms.
Library docs
An object representing something that can be scrolled. This interface is implemented by states of
scrollable containers such as androidx.compose.foundation.lazy.LazyListState or
androidx.compose.foundation.ScrollState in order to provide low-level scrolling control via
scroll, as well as allowing for higher-level scrolling functions like animateScrollBy to be
implemented as extension functions on ScrollableState.
Subclasses may also have their own methods that are specific to their interaction paradigm, such
as androidx.compose.foundation.lazy.LazyListState.scrollToItem.