# RecyclerView.SmoothScroller.ScrollVectorProvider

Artifact: [androidx.recyclerview:recyclerview](https://developer.android.com/jetpack/androidx/releases/recyclerview) [View Source](https://cs.android.com/search?q=file:androidx/recyclerview/widget/RecyclerView.java+class:androidx.recyclerview.widget.RecyclerView.SmoothScroller.ScrollVectorProvider) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

*** ** * ** ***


```
public interface RecyclerView.SmoothScroller.ScrollVectorProvider
```

<br />

Known direct subclasses [LinearLayoutManager](https://developer.android.com/reference/androidx/recyclerview/widget/LinearLayoutManager), [StaggeredGridLayoutManager](https://developer.android.com/reference/androidx/recyclerview/widget/StaggeredGridLayoutManager)

|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/LinearLayoutManager` | A `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.LayoutManager` implementation which provides similar functionality to `https://developer.android.com/reference/android/widget/ListView.html`. |
| `https://developer.android.com/reference/androidx/recyclerview/widget/StaggeredGridLayoutManager` | A LayoutManager that lays out children in a staggered grid formation. |

Known indirect subclasses [GridLayoutManager](https://developer.android.com/reference/androidx/recyclerview/widget/GridLayoutManager), [WearableLinearLayoutManager](https://developer.android.com/reference/androidx/wear/widget/WearableLinearLayoutManager)

|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/GridLayoutManager` | A `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.LayoutManager` implementations that lays out items in a grid. |
| `https://developer.android.com/reference/androidx/wear/widget/WearableLinearLayoutManager` | This wear-specific implementation of `https://developer.android.com/reference/androidx/recyclerview/widget/LinearLayoutManager` provides basic offsetting logic for updating child layout. |

*** ** * ** ***

An interface which is optionally implemented by custom `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.LayoutManager` to provide a hint to a `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.SmoothScroller` about the location of the target position.

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.SmoothScroller.ScrollVectorProvider#computeScrollVectorForPosition(int)(int targetPosition)` Should calculate the vector that points to the direction where the target position can be found. |

## Public methods

### computeScrollVectorForPosition

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

```
abstract @Nullable PointF computeScrollVectorForPosition(int targetPosition)
```

Should calculate the vector that points to the direction where the target position can be found.

This method is used by the `https://developer.android.com/reference/androidx/recyclerview/widget/LinearSmoothScroller` to initiate a scroll towards the target position.

The magnitude of the vector is not important. It is always normalized before being used by the `https://developer.android.com/reference/androidx/recyclerview/widget/LinearSmoothScroller`.

LayoutManager should not check whether the position exists in the adapter or not.

| Parameters |
|---|---|
| `int targetPosition` | the target position to which the returned vector should point |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/graphics/PointF.html` | the scroll vector for a given position. |