public class CenterSnapHelper
extends RecyclerView.OnFlingListener
RecyclerView
which use BannerLayoutManager as its LayoutManager.
The implementation will snap the center of the target child view to the center of
the attached RecyclerView.
| Constructor and Description |
|---|
CenterSnapHelper() |
| Modifier and Type | Method and Description |
|---|---|
void |
attachToRecyclerView(RecyclerView recyclerView)
Please attach after {
LayoutManager is setting}
Attaches the CenterSnapHelper to the provided RecyclerView, by calling
RecyclerView#setOnFlingListener(RecyclerView.OnFlingListener). |
boolean |
onFling(int velocityX,
int velocityY) |
public boolean onFling(int velocityX,
int velocityY)
public void attachToRecyclerView(RecyclerView recyclerView)
throws java.lang.IllegalStateException
LayoutManager is setting}
Attaches the CenterSnapHelper to the provided RecyclerView, by calling
RecyclerView#setOnFlingListener(RecyclerView.OnFlingListener).
You can call this method with null to detach it from the current RecyclerView.recyclerView - The RecyclerView instance to which you want to add this helper or
null if you want to remove CenterSnapHelper from the current
RecyclerView.java.lang.IllegalArgumentException - if there is already a RecyclerView.OnFlingListener
attached to the provided RecyclerView.java.lang.IllegalStateException