# RecyclerView.SmoothScroller.ScrollVectorProvider

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.SmoothScroller.ScrollVectorProvider "View this page in Java")

<br />

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

<br />

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

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

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

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

*** ** * ** ***

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

## Summary

|                               ### Public functions                                |
|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [PointF](https://developer.android.com/reference/android/graphics/PointF.html)`?` | [computeScrollVectorForPosition](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.SmoothScroller.ScrollVectorProvider#computeScrollVectorForPosition(int))`(targetPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Should calculate the vector that points to the direction where the target position can be found. |

## Public functions

### computeScrollVectorForPosition

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

```
fun computeScrollVectorForPosition(targetPosition: Int): PointF?
```

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

This method is used by the[LinearSmoothScroller](https://developer.android.com/reference/kotlin/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[LinearSmoothScroller](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/LinearSmoothScroller).

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

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| `targetPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the target position to which the returned vector should point |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|-----------------------------------------|
| [PointF](https://developer.android.com/reference/android/graphics/PointF.html)`?` | the scroll vector for a given position. |