Google 致力于为黑人社区推动种族平等。查看具体举措

ScrollerCompat

class ScrollerCompat
kotlin.Any
   ↳ androidx.core.widget.ScrollerCompat

Provides access to new Scroller APIs when available.

This class provides a platform version-independent mechanism for obeying the current device's preferred scroll physics and fling behavior. It offers a subset of the APIs from Scroller or OverScroller.

Summary

Public methods
Unit

Stops the animation.

Boolean

Call this when you want to know the new location.

static ScrollerCompat!
create(context: Context!)

static ScrollerCompat!
create(context: Context!, interpolator: Interpolator!)

Unit
fling(startX: Int, startY: Int, velocityX: Int, velocityY: Int, minX: Int, maxX: Int, minY: Int, maxY: Int)

Start scrolling based on a fling gesture.

Unit
fling(startX: Int, startY: Int, velocityX: Int, velocityY: Int, minX: Int, maxX: Int, minY: Int, maxY: Int, overX: Int, overY: Int)

Start scrolling based on a fling gesture.

Float

Returns the current velocity on platform versions that support it.

Int

Returns the current X offset in the scroll.

Int

Returns the current Y offset in the scroll.

Int

Int

Boolean

Returns whether the scroller has finished scrolling.

Boolean

Returns whether the current Scroller is currently returning to a valid position.

Unit
notifyHorizontalEdgeReached(startX: Int, finalX: Int, overX: Int)

Notify the scroller that we've reached a horizontal boundary.

Unit
notifyVerticalEdgeReached(startY: Int, finalY: Int, overY: Int)

Notify the scroller that we've reached a vertical boundary.

Boolean
springBack(startX: Int, startY: Int, minX: Int, maxX: Int, minY: Int, maxY: Int)

Call this when you want to 'spring back' into a valid coordinate range.

Unit
startScroll(startX: Int, startY: Int, dx: Int, dy: Int)

Start scrolling by providing a starting point and the distance to travel.

Unit
startScroll(startX: Int, startY: Int, dx: Int, dy: Int, duration: Int