public class PagerGridSnapHelper
extends androidx.recyclerview.widget.SnapHelper
构造器和说明 |
---|
PagerGridSnapHelper() |
限定符和类型 | 方法和说明 |
---|---|
void |
attachToRecyclerView(androidx.recyclerview.widget.RecyclerView recyclerView)
用于将滚动工具和 Recycler 绑定
|
int[] |
calculateDistanceToFinalSnap(androidx.recyclerview.widget.RecyclerView.LayoutManager layoutManager,
android.view.View targetView)
计算需要滚动的向量,用于页面自动回滚对齐
|
protected androidx.recyclerview.widget.LinearSmoothScroller |
createSnapScroller(androidx.recyclerview.widget.RecyclerView.LayoutManager layoutManager)
通过自定义 LinearSmoothScroller 来控制速度
|
android.view.View |
findSnapView(androidx.recyclerview.widget.RecyclerView.LayoutManager layoutManager)
获得需要对齐的View,对于分页布局来说,就是页面第一个
|
int |
findTargetSnapPosition(androidx.recyclerview.widget.RecyclerView.LayoutManager layoutManager,
int velocityX,
int velocityY)
获取目标控件的位置下标
(获取滚动后第一个View的下标)
|
boolean |
onFling(int velocityX,
int velocityY)
一扔(快速滚动)
|
void |
setFlingThreshold(int threshold)
设置滚动阀值
|
public void attachToRecyclerView(@Nullable androidx.recyclerview.widget.RecyclerView recyclerView) throws java.lang.IllegalStateException
attachToRecyclerView
在类中 androidx.recyclerview.widget.SnapHelper
recyclerView
- RecyclerViewjava.lang.IllegalStateException
- 状态异常@Nullable public int[] calculateDistanceToFinalSnap(@NonNull androidx.recyclerview.widget.RecyclerView.LayoutManager layoutManager, @NonNull android.view.View targetView)
calculateDistanceToFinalSnap
在类中 androidx.recyclerview.widget.SnapHelper
layoutManager
- 布局管理器targetView
- 目标控件@Nullable public android.view.View findSnapView(androidx.recyclerview.widget.RecyclerView.LayoutManager layoutManager)
findSnapView
在类中 androidx.recyclerview.widget.SnapHelper
layoutManager
- 布局管理器public int findTargetSnapPosition(androidx.recyclerview.widget.RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY)
findTargetSnapPosition
在类中 androidx.recyclerview.widget.SnapHelper
layoutManager
- 布局管理器velocityX
- X 轴滚动速率velocityY
- Y 轴滚动速率public boolean onFling(int velocityX, int velocityY)
onFling
在类中 androidx.recyclerview.widget.SnapHelper
velocityX
- X 轴滚动速率velocityY
- Y 轴滚动速率protected androidx.recyclerview.widget.LinearSmoothScroller createSnapScroller(androidx.recyclerview.widget.RecyclerView.LayoutManager layoutManager)
createSnapScroller
在类中 androidx.recyclerview.widget.SnapHelper
layoutManager
- 布局故哪里去public void setFlingThreshold(int threshold)
threshold
- 滚动阀值