# ScrollerCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/widget/ScrollerCompat.java+class:androidx.core.widget.ScrollerCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public final class ScrollerCompat
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html` directly.

Provides access to new `https://developer.android.com/reference/android/widget/Scroller.html` 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 |
|---|---|
| `void` | `[abortAnimation](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#abortAnimation())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#abortAnimation()` directly. <br /> |
| `boolean` | `[computeScrollOffset](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#computeScrollOffset())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#computeScrollOffset()` directly. <br /> |
| `static https://developer.android.com/reference/androidx/core/widget/ScrollerCompat` | `[create](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#create(android.content.Context))(https://developer.android.com/reference/android/content/Context.html context)` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html` constructor directly. <br /> |
| `static https://developer.android.com/reference/androidx/core/widget/ScrollerCompat` | `[create](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#create(android.content.Context,android.view.animation.Interpolator))(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/view/animation/Interpolator.html interpolator)` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html` constructor directly. <br /> |
| `void` | `[fling](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#fling(int,int,int,int,int,int,int,int))( int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY )` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#fling(int, int, int, int, int, int, int, int)` directly. <br /> |
| `void` | `[fling](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#fling(int,int,int,int,int,int,int,int,int,int))( int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY, int overX, int overY )` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#fling(int, int, int, int, int, int, int, int, int, int)` directly. <br /> |
| `float` | `[getCurrVelocity](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getCurrVelocity())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#getCurrVelocity()` directly. <br /> |
| `int` | `[getCurrX](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getCurrX())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#getCurrX()` directly. <br /> |
| `int` | `[getCurrY](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getCurrY())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#getCurrY()` directly. <br /> |
| `int` | `[getFinalX](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getFinalX())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#getFinalX()` directly. <br /> |
| `int` | `[getFinalY](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getFinalY())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#getFinalY()` directly. <br /> |
| `boolean` | `[isFinished](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#isFinished())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#isFinished()` directly. <br /> |
| `boolean` | `[isOverScrolled](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#isOverScrolled())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#isOverScrolled()` directly. <br /> |
| `void` | `[notifyHorizontalEdgeReached](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#notifyHorizontalEdgeReached(int,int,int))(int startX, int finalX, int overX)` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#notifyHorizontalEdgeReached(int, int, int)` directly. <br /> |
| `void` | `[notifyVerticalEdgeReached](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#notifyVerticalEdgeReached(int,int,int))(int startY, int finalY, int overY)` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#notifyVerticalEdgeReached(int, int, int)` directly. <br /> |
| `boolean` | `[springBack](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#springBack(int,int,int,int,int,int))(int startX, int startY, int minX, int maxX, int minY, int maxY)` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#springBack(int, int, int, int, int, int)` directly. <br /> |
| `void` | `[startScroll](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#startScroll(int,int,int,int))(int startX, int startY, int dx, int dy)` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#getCurrX()` directly. <br /> |
| `void` | `[startScroll](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#startScroll(int,int,int,int,int))(int startX, int startY, int dx, int dy, int duration)` **This method is deprecated.** Use `https://developer.android.com/reference/android/widget/OverScroller.html#startScroll(int, int, int, int, int)` directly. <br /> |

## Public methods

### abortAnimation

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void [abortAnimation](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#abortAnimation())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#abortAnimation()` directly.

Stops the animation. Aborting the animation causes the scroller to move to the final x and y position.

### computeScrollOffset

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean [computeScrollOffset](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#computeScrollOffset())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#computeScrollOffset()` directly.

Call this when you want to know the new location. If it returns true, the animation is not yet finished. loc will be altered to provide the new location.

### create

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static ScrollerCompat [create](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#create(android.content.Context))(Context context)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html` constructor directly.

### create

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static ScrollerCompat [create](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#create(android.content.Context,android.view.animation.Interpolator))(Context context, Interpolator interpolator)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html` constructor directly.

### fling

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void [fling](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#fling(int,int,int,int,int,int,int,int))(
    int startX,
    int startY,
    int velocityX,
    int velocityY,
    int minX,
    int maxX,
    int minY,
    int maxY
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#fling(int, int, int, int, int, int, int, int)` directly.

Start scrolling based on a fling gesture. The distance travelled will depend on the initial velocity of the fling.

| Parameters |
|---|---|
| `int startX` | Starting point of the scroll (X) |
| `int startY` | Starting point of the scroll (Y) |
| `int velocityX` | Initial velocity of the fling (X) measured in pixels per second. |
| `int velocityY` | Initial velocity of the fling (Y) measured in pixels per second |
| `int minX` | Minimum X value. The scroller will not scroll past this point. |
| `int maxX` | Maximum X value. The scroller will not scroll past this point. |
| `int minY` | Minimum Y value. The scroller will not scroll past this point. |
| `int maxY` | Maximum Y value. The scroller will not scroll past this point. |

### fling

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void [fling](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#fling(int,int,int,int,int,int,int,int,int,int))(
    int startX,
    int startY,
    int velocityX,
    int velocityY,
    int minX,
    int maxX,
    int minY,
    int maxY,
    int overX,
    int overY
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#fling(int, int, int, int, int, int, int, int, int, int)` directly.

Start scrolling based on a fling gesture. The distance travelled will depend on the initial velocity of the fling.

| Parameters |
|---|---|
| `int startX` | Starting point of the scroll (X) |
| `int startY` | Starting point of the scroll (Y) |
| `int velocityX` | Initial velocity of the fling (X) measured in pixels per second. |
| `int velocityY` | Initial velocity of the fling (Y) measured in pixels per second |
| `int minX` | Minimum X value. The scroller will not scroll past this point. |
| `int maxX` | Maximum X value. The scroller will not scroll past this point. |
| `int minY` | Minimum Y value. The scroller will not scroll past this point. |
| `int maxY` | Maximum Y value. The scroller will not scroll past this point. |
| `int overX` | Overfling range. If \>0, horizontal overfling in either direction will be possible. |
| `int overY` | Overfling range. If \>0, vertical overfling in either direction will be possible. |

### getCurrVelocity

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public float [getCurrVelocity](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getCurrVelocity())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#getCurrVelocity()` directly.

Returns the current velocity on platform versions that support it.

This method should only be used as input for nonessential visual effects such as `https://developer.android.com/reference/androidx/core/widget/EdgeEffectCompat`.

| Returns |
|---|---|
| `float` | The original velocity less the deceleration. Result may be negative. |

### getCurrX

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int [getCurrX](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getCurrX())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#getCurrX()` directly.

Returns the current X offset in the scroll.

| Returns |
|---|---|
| `int` | The new X offset as an absolute distance from the origin. |

### getCurrY

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int [getCurrY](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getCurrY())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#getCurrY()` directly.

Returns the current Y offset in the scroll.

| Returns |
|---|---|
| `int` | The new Y offset as an absolute distance from the origin. |

### getFinalX

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int [getFinalX](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getFinalX())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#getFinalX()` directly.

| Returns |
|---|---|
| `int` | The final X position for the scroll in progress, if known. |

### getFinalY

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public int [getFinalY](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#getFinalY())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#getFinalY()` directly.

| Returns |
|---|---|
| `int` | The final Y position for the scroll in progress, if known. |

### isFinished

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean [isFinished](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#isFinished())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#isFinished()` directly.

Returns whether the scroller has finished scrolling.

| Returns |
|---|---|
| `boolean` | True if the scroller has finished scrolling, false otherwise. |

### isOverScrolled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean [isOverScrolled](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#isOverScrolled())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#isOverScrolled()` directly.

Returns whether the current Scroller is currently returning to a valid position. Valid bounds were provided by the `https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#fling(int,int,int,int,int,int,int,int,int,int)` method. One should check this value before calling `https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#startScroll(int,int,int,int)` as the interpolation currently in progress to restore a valid position will then be stopped. The caller has to take into account the fact that the started scroll will start from an overscrolled position.

| Returns |
|---|---|
| `boolean` | true when the current position is overscrolled and in the process of interpolating back to a valid value. |

### notifyHorizontalEdgeReached

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void [notifyHorizontalEdgeReached](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#notifyHorizontalEdgeReached(int,int,int))(int startX, int finalX, int overX)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#notifyHorizontalEdgeReached(int, int, int)` directly.

Notify the scroller that we've reached a horizontal boundary. Normally the information to handle this will already be known when the animation is started, such as in a call to one of the fling functions. However there are cases where this cannot be known in advance. This function will transition the current motion and animate from startX to finalX as appropriate.

| Parameters |
|---|---|
| `int startX` | Starting/current X position |
| `int finalX` | Desired final X position |
| `int overX` | Magnitude of overscroll allowed. This should be the maximum desired distance from finalX. Absolute value - must be positive. |

### notifyVerticalEdgeReached

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void [notifyVerticalEdgeReached](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#notifyVerticalEdgeReached(int,int,int))(int startY, int finalY, int overY)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#notifyVerticalEdgeReached(int, int, int)` directly.

Notify the scroller that we've reached a vertical boundary. Normally the information to handle this will already be known when the animation is started, such as in a call to one of the fling functions. However there are cases where this cannot be known in advance. This function will animate a parabolic motion from startY to finalY.

| Parameters |
|---|---|
| `int startY` | Starting/current Y position |
| `int finalY` | Desired final Y position |
| `int overY` | Magnitude of overscroll allowed. This should be the maximum desired distance from finalY. Absolute value - must be positive. |

### springBack

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean [springBack](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#springBack(int,int,int,int,int,int))(int startX, int startY, int minX, int maxX, int minY, int maxY)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#springBack(int, int, int, int, int, int)` directly.

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

| Parameters |
|---|---|
| `int startX` | Starting X coordinate |
| `int startY` | Starting Y coordinate |
| `int minX` | Minimum valid X value |
| `int maxX` | Maximum valid X value |
| `int minY` | Minimum valid Y value |
| `int maxY` | Maximum valid Y value |

| Returns |
|---|---|
| `boolean` | true if a springback was initiated, false if startX and startY were already within the valid range. |

### startScroll

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void [startScroll](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#startScroll(int,int,int,int))(int startX, int startY, int dx, int dy)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#getCurrX()` directly.

Start scrolling by providing a starting point and the distance to travel. The scroll will use the default value of 250 milliseconds for the duration.

| Parameters |
|---|---|
| `int startX` | Starting horizontal scroll offset in pixels. Positive numbers will scroll the content to the left. |
| `int startY` | Starting vertical scroll offset in pixels. Positive numbers will scroll the content up. |
| `int dx` | Horizontal distance to travel. Positive numbers will scroll the content to the left. |
| `int dy` | Vertical distance to travel. Positive numbers will scroll the content up. |

### startScroll

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void [startScroll](https://developer.android.com/reference/androidx/core/widget/ScrollerCompat#startScroll(int,int,int,int,int))(int startX, int startY, int dx, int dy, int duration)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/widget/OverScroller.html#startScroll(int, int, int, int, int)` directly.

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

| Parameters |
|---|---|
| `int startX` | Starting horizontal scroll offset in pixels. Positive numbers will scroll the content to the left. |
| `int startY` | Starting vertical scroll offset in pixels. Positive numbers will scroll the content up. |
| `int dx` | Horizontal distance to travel. Positive numbers will scroll the content to the left. |
| `int dy` | Vertical distance to travel. Positive numbers will scroll the content up. |
| `int duration` | Duration of the scroll in milliseconds. |