The second Android 11 Developer Preview is now available, test it out and share your feedback.

ScrollerPosition

@Model class ScrollerPosition
kotlin.Any
   ↳ androidx.ui.foundation.ScrollerPosition

This is the state of a VerticalScroller and HorizontalScroller that allows the developer to change the scroll position by calling methods on this object.

Summary

Public constructors

<init>(flingConfig: FlingConfig, initial: Float = 0f, animationClock: AnimationClockObservable)

This is the state of a VerticalScroller and HorizontalScroller that allows the developer to change the scroll position by calling methods on this object.

Public methods

Unit
scrollBy(value: Float)

Instantly jump by some amount of pixels

Unit
scrollTo(value: Float)

Instantly jump to position in pixels

Unit
smoothScrollBy(value: Float, onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> })

Smooth scroll by some amount of pixels

Unit
smoothScrollTo(value: Float, onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> })

Smooth scroll to position in pixels

Properties

Boolean

whether this ScrollerPosition is currently animating/flinging

Float

maxPosition this scroller that consume this ScrollerPosition can reach, or Float.POSITIVE_INFINITY if still unknown

Float

current scroller position value

Public constructors

<init>

ScrollerPosition(
    flingConfig: FlingConfig,
    initial: Float = 0f,
    animationClock: AnimationClockObservable)

This is the state of a VerticalScroller and HorizontalScroller that allows the developer to change the scroll position by calling methods on this object.

Parameters
flingConfig: FlingConfig configuration that specifies fling logic when scrolling ends with velocity
initial: Float = 0f initial scroller position to start with
animationClock: AnimationClockObservable clock observable to run animation on. Consider querying AnimationClockAmbient to get current composition value

Public methods

scrollBy

fun scrollBy(value: Float): Unit

Instantly jump by some amount of pixels

Parameters
value: Float delta to jump by, total value will be coerced to 0..maxPosition

scrollTo

fun scrollTo(value: Float): Unit

Instantly jump to position in pixels

Parameters
value: Float target value to jump to, value will be coerced to 0..maxPosition

smoothScrollBy

fun smoothScrollBy(
    value: Float,
    onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> }
): Unit

Smooth scroll by some amount of pixels

Parameters
value: Float delta to scroll by, total value will be coerced to 0..maxPosition

smoothScrollTo

fun smoothScrollTo(
    value: Float,
    onEnd: (endReason: AnimationEndReason, finishValue: Float) -> Unit = { _, _ -> }
): Unit

Smooth scroll to position in pixels

Parameters
value: Float target value to smooth scroll to, value will be coerced to 0..maxPosition

Properties

isAnimating

val isAnimating: Boolean

whether this ScrollerPosition is currently animating/flinging

maxPosition

var maxPosition: Float

maxPosition this scroller that consume this ScrollerPosition can reach, or Float.POSITIVE_INFINITY if still unknown

value

var value: Float

current scroller position value