androidx.compose.foundation
ScrollState
Class · from org.jetbrains.compose.foundation:foundation:1.12.2
No hand-written docs yet.
State of the scroll. Allows the developer to change the scroll position or get current state by calling methods on this object. To be hosted and passed to Modifier.verticalScroll or Modifier.horizontalScroll
class ScrollState(
initial: Int,
) : ScrollableState
Is a
How to get one
Create it
ScrollState(initial)constructor
Used by
Parameters that take a ScrollState.
BasicSecureTextField(scrollState)BasicTextField(scrollState)DropdownMenu(scrollState)ExposedDropdownMenuBoxScope.ExposedDropdownMenu(scrollState)horizontalScroll(state)OutlinedTextField(scrollState)PrimaryScrollableTabRow(scrollState)SearchBarDefaults.InputField(scrollState)SecondaryScrollableTabRow(scrollState)TextField(scrollState)verticalScroll(state)
Properties
value
val value: Int
current scroll position value in pixels
maxValue
val maxValue: Int
maximum bound for value, or Int.MAX_VALUE if still unknown
viewportSize
val viewportSize: Int
Size of the viewport on the scrollable axis, or 0 if still unknown. Note that this value is only populated after the first measure pass.
interactionSource
val interactionSource: InteractionSource
InteractionSource that will be used to dispatch drag events when this list is being dragged. If you want to know whether the fling (or smooth scroll) is in progress, use isScrollInProgress.
Saver
val Saver: Saver<ScrollState, *>
The default Saver implementation for ScrollState.
Functions
animateScrollTo
fun animateScrollTo(
value: Int,
animationSpec: AnimationSpec<Float> = SpringSpec(),
)
Scroll to position in pixels with animation.
scrollTo
fun scrollTo(value: Int): Float
Instantly jump to the given position in pixels.
Library docs
State of the scroll. Allows the developer to change the scroll position or get current state by
calling methods on this object. To be hosted and passed to Modifier.verticalScroll or
Modifier.horizontalScroll
To create and automatically remember ScrollState with default parameters use
rememberScrollState.
Learn how to control the state of Modifier.verticalScroll or Modifier.horizontalScroll: