LinearSnapHelper
class LinearSnapHelper : SnapHelper
| kotlin.Any | |||
| ↳ | androidx.recyclerview.widget.RecyclerView.OnFlingListener | ||
| ↳ | androidx.recyclerview.widget.SnapHelper | ||
| ↳ | androidx.recyclerview.widget.LinearSnapHelper |
Implementation of the SnapHelper supporting snapping in either vertical or horizontal orientation.
The implementation will snap the center of the target child view to the center of the attached RecyclerView. If you intend to change this behavior then override calculateDistanceToFinalSnap.
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
IntArray<Int>! |
calculateDistanceToFinalSnap(Override this method to snap to a particular point within the target view or the container view on any axis. |
View! |
findSnapView(layoutManager: RecyclerView.LayoutManager!)Override this method to provide a particular target view for snapping. |
Int |
findTargetSnapPosition(Override to provide a particular adapter target position for snapping. |
Inherited functions |
||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
Public functions
calculateDistanceToFinalSnap
fun calculateDistanceToFinalSnap(
layoutManager: RecyclerView.LayoutManager,
targetView: View
): IntArray<Int>!
Override this method to snap to a particular point within the target view or the container view on any axis.
This method is called when the SnapHelper has intercepted a fling and it needs to know the exact distance required to scroll by in order to snap to the target view.
| Parameters | |
|---|---|
layoutManager: RecyclerView.LayoutManager |
the |
targetView: View |
the target view that is chosen as the view to snap |
findSnapView
fun findSnapView(layoutManager: RecyclerView.LayoutManager!): View!
Override this method to provide a particular target view for snapping.
This method is called when the SnapHelper is ready to start snapping and requires a target view to snap to. It will be explicitly called when the scroll state becomes idle after a scroll. It will also be called when the SnapHelper is preparing to snap after a fling and requires a reference view from the current set of child views.
If this method returns null, SnapHelper will not snap to any view.
| Parameters | |
|---|---|
layoutManager: RecyclerView.LayoutManager! |
the |
| Returns | |
|---|---|
View! |
the target view to which to snap on fling or end of scroll |
findTargetSnapPosition
fun findTargetSnapPosition(
layoutManager: RecyclerView.LayoutManager!,
velocityX: Int,
velocityY: Int
): Int
Override to provide a particular adapter target position for snapping.
| Parameters | |
|---|---|
layoutManager: RecyclerView.LayoutManager! |
the |
velocityX: Int |
fling velocity on the horizontal axis |
velocityY: Int |
fling velocity on the vertical axis |
| Returns | |
|---|---|
Int |
the target adapter position to you want to snap or |