public class SnappyRecyclerView extends RecyclerView implements SnappyAdapter.Snapper
| Modifier and Type | Class and Description |
|---|---|
static class |
SnappyRecyclerView.Behavior |
| Constructor and Description |
|---|
SnappyRecyclerView(android.content.Context context) |
SnappyRecyclerView(android.content.Context context,
android.util.AttributeSet attrs) |
SnappyRecyclerView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyle) |
| Modifier and Type | Method and Description |
|---|---|
void |
enableSnapListener(SnappyRecyclerView.Behavior behavior)
Enables scroll listener that will notify on snapped item change
|
int |
getCurrentPosition() |
int |
getSnappedPosition() |
boolean |
isPaddingApplied() |
boolean |
notifyOnSnap() |
protected void |
onLayout(boolean changed,
int l,
int t,
int r,
int b) |
void |
resetCenteringPadding(int itemSize,
int edgeMargin,
int position)
Resets required padding to place items in the center
|
void |
resetCenteringPadding(android.view.View target,
int position)
Resets required padding to place items in the center.
|
void |
setAdapter(Adapter adapter) |
void |
setCenteringPadding(int itemSize,
int edgeMargin,
int position)
Sets required padding to place items in the center
|
void |
setCenteringPadding(android.view.View target,
int position)
Sets required padding to place items in the center.
|
void |
setCustomSnapHelper(LinearSnapHelper snapHelper) |
void |
setLayoutManager(LayoutManager layout) |
void |
smoothSnapBy(int dx,
int dy)
Smothly scrolls to position by pixels
|
void |
smoothSnapToPosition(int position)
Smothly scrolls to position
|
void |
snapToPosition(int position)
Instantly scrolls to position
|
public SnappyRecyclerView(android.content.Context context)
public SnappyRecyclerView(android.content.Context context,
android.util.AttributeSet attrs)
public SnappyRecyclerView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyle)
public void setCustomSnapHelper(LinearSnapHelper snapHelper)
public final void setCenteringPadding(int itemSize,
int edgeMargin,
int position)
itemSize - height (if orientation is vertical) or weight (if orientation is horizontal) of the itemedgeMargin - edge margin (e.g. left for vertical and top for horizontal orientation) of the itemposition - initial position of the centered item (usually position = 0)public final void resetCenteringPadding(int itemSize,
int edgeMargin,
int position)
itemSize - height (if orientation is vertical) or weight (if orientation is horizontal) of the itemedgeMargin - edge margin (e.g. left for vertical and top for horizontal orientation) of the itemposition - initial position of the centered item (usually position = 0)public final void setCenteringPadding(android.view.View target,
int position)
target - the view that is identical to item viewposition - initial position of the centered item (usually position = 0)public final void resetCenteringPadding(android.view.View target,
int position)
target - the view that is identical to item viewposition - initial position of the centered item (usually position = 0)public void setLayoutManager(LayoutManager layout)
public final void enableSnapListener(SnappyRecyclerView.Behavior behavior)
public void setAdapter(Adapter adapter)
public int getSnappedPosition()
getSnappedPosition in interface SnappyAdapter.Snapperpublic int getCurrentPosition()
public boolean notifyOnSnap()
public void smoothSnapToPosition(int position)
smoothSnapToPosition in interface SnappyAdapter.Snapperposition - position of the item that will be placed in the centerpublic void smoothSnapBy(int dx,
int dy)
smoothSnapBy in interface SnappyAdapter.Snapperpublic void snapToPosition(int position)
snapToPosition in interface SnappyAdapter.Snapperpublic boolean isPaddingApplied()
protected void onLayout(boolean changed,
int l,
int t,
int r,
int b)