public class OverFlyingLayoutManager
extends RecyclerView.LayoutManager
| Modifier and Type | Class and Description |
|---|---|
static interface |
OverFlyingLayoutManager.OnPageChangeListener |
| Modifier and Type | Field and Description |
|---|---|
static int |
DETERMINE_BY_MAX_AND_MIN |
static int |
HORIZONTAL |
protected int |
mDecoratedMeasurement |
protected int |
mDecoratedMeasurementInOther |
protected float |
mInterval |
protected float |
mOffset
The offset of property which will change while scrolling
|
protected OrientationHelper |
mOrientationHelper
Many calculations are made depending on orientation.
|
protected int |
mSpaceInOther |
protected int |
mSpaceMain |
static int |
VERTICAL |
| Constructor and Description |
|---|
OverFlyingLayoutManager(android.content.Context context)
Creates a horizontal ViewPagerLayoutManager
|
OverFlyingLayoutManager(float minScale,
int itemSpace,
int orientation) |
OverFlyingLayoutManager(int orientation,
boolean reverseLayout) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
calItemLeft(android.view.View itemView,
float targetOffset) |
protected int |
calItemTop(android.view.View itemView,
float targetOffset) |
boolean |
canScrollHorizontally() |
boolean |
canScrollVertically() |
int |
computeHorizontalScrollExtent(RecyclerView.State state) |
int |
computeHorizontalScrollOffset(RecyclerView.State state) |
int |
computeHorizontalScrollRange(RecyclerView.State state) |
android.graphics.PointF |
computeScrollVectorForPosition(int targetPosition) |
int |
computeVerticalScrollExtent(RecyclerView.State state) |
int |
computeVerticalScrollOffset(RecyclerView.State state) |
int |
computeVerticalScrollRange(RecyclerView.State state) |
RecyclerView.LayoutParams |
generateDefaultLayoutParams() |
float |
getAngle() |
int |
getCurrentPosition() |
protected float |
getDistanceRatio() |
boolean |
getEnableBringCenterToFront() |
boolean |
getInfinite() |
int |
getItemSpace() |
int |
getMaxVisibleItemCount()
Returns the max visible item count,
DETERMINE_BY_MAX_AND_MIN means it haven't been set now
And it will use maxRemoveOffset() and minRemoveOffset() to handle the range |
float |
getMinScale() |
int |
getOffsetToCenter() |
int |
getOrientation()
Returns the current orientation of the layout.
|
boolean |
getRecycleChildrenOnDetach()
Returns whether LayoutManager will recycle its children when it is detached from
RecyclerView.
|
boolean |
getReverseLayout()
Returns if views are laid out from the opposite direction of the layout.
|
boolean |
getSmoothScrollbarEnabled()
Returns the current state of the smooth scrollbar feature.
|
int |
getTotalSpaceInOther() |
boolean |
isIntegerDy()
see
mIntegerDy |
protected float |
maxRemoveOffset()
when the target offset reach this,
the view will be removed and recycled in
layoutItems(RecyclerView.Recycler) |
protected float |
minRemoveOffset()
when the target offset reach this,
the view will be removed and recycled in
layoutItems(RecyclerView.Recycler) |
void |
onAdapterChanged(RecyclerView.Adapter oldAdapter,
RecyclerView.Adapter newAdapter) |
void |
onDetachedFromWindow(RecyclerView view,
RecyclerView.Recycler recycler) |
void |
onLayoutChildren(RecyclerView.Recycler recycler,
RecyclerView.State state) |
void |
onLayoutCompleted(RecyclerView.State state) |
void |
onRestoreInstanceState(android.os.Parcelable state) |
android.os.Parcelable |
onSaveInstanceState() |
protected float |
propertyChangeWhenScroll(android.view.View itemView) |
int |
scrollHorizontallyBy(int dx,
RecyclerView.Recycler recycler,
RecyclerView.State state) |
void |
scrollToPosition(int position) |
int |
scrollVerticallyBy(int dy,
RecyclerView.Recycler recycler,
RecyclerView.State state) |
void |
setAngle(float angle) |
void |
setEnableBringCenterToFront(boolean bringCenterToTop) |
void |
setInfinite(boolean enable) |
void |
setIntegerDy(boolean mIntegerDy)
see
mIntegerDy |
protected float |
setInterval() |
void |
setItemSpace(int itemSpace) |
protected void |
setItemViewProperty(android.view.View itemView,
float targetOffset) |
void |
setMaxVisibleItemCount(int mMaxVisibleItemCount)
Set the max visible item count,
DETERMINE_BY_MAX_AND_MIN means it haven't been set now
And it will use maxRemoveOffset() and minRemoveOffset() to handle the range |
void |
setMinScale(float minScale) |
void |
setOnPageChangeListener(OverFlyingLayoutManager.OnPageChangeListener onPageChangeListener) |
void |
setOrientation(int orientation)
will do its best to keep scroll position.
|
void |
setRecycleChildrenOnDetach(boolean recycleChildrenOnDetach)
Set whether LayoutManager will recycle its children when it is detached from
RecyclerView.
|
void |
setReverseLayout(boolean reverseLayout)
Used to reverse item traversal and layout order.
|
void |
setSmoothScrollbarEnabled(boolean enabled)
When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computed
based on the number of visible pixels in the visible items.
|
protected void |
setUp()
You can set up your own properties here or change the exist properties like mSpaceMain and mSpaceInOther
|
protected float |
setViewElevation(android.view.View itemView,
float targetOffset)
cause elevation is not support below api 21,
so you can set your elevation here for supporting it below api 21
or you can just setElevation in
setItemViewProperty(View, float) |
void |
smoothScrollToPosition(RecyclerView recyclerView,
RecyclerView.State state,
int position) |
public static final int DETERMINE_BY_MAX_AND_MIN
public static final int HORIZONTAL
public static final int VERTICAL
protected int mDecoratedMeasurement
protected int mDecoratedMeasurementInOther
protected int mSpaceMain
protected int mSpaceInOther
protected float mOffset
protected OrientationHelper mOrientationHelper
LinearLayoutManager make those decisions.
Based on mOrientation, an implementation is lazily created in
ensureLayoutState() method.protected float mInterval
public OverFlyingLayoutManager(android.content.Context context)
public OverFlyingLayoutManager(int orientation,
boolean reverseLayout)
orientation - Layout orientation. Should be HORIZONTAL or VERTICALreverseLayout - When set to true, layouts from end to startpublic OverFlyingLayoutManager(float minScale,
int itemSpace,
int orientation)
public float getMinScale()
public void setMinScale(float minScale)
public float getAngle()
public void setAngle(float angle)
public int getItemSpace()
public void setItemSpace(int itemSpace)
protected float setInterval()
protected void setItemViewProperty(android.view.View itemView,
float targetOffset)
protected float setViewElevation(android.view.View itemView,
float targetOffset)
setItemViewProperty(View, float)public RecyclerView.LayoutParams generateDefaultLayoutParams()
public boolean getRecycleChildrenOnDetach()
public void setRecycleChildrenOnDetach(boolean recycleChildrenOnDetach)
If you are using a RecyclerView.RecycledViewPool, it might be a good idea to set
this flag to true so that views will be available to other RecyclerViews
immediately.
Note that, setting this flag will result in a performance drop if RecyclerView is restored.
recycleChildrenOnDetach - Whether children should be recycled in detach or not.public void onDetachedFromWindow(RecyclerView view,
RecyclerView.Recycler recycler)
public android.os.Parcelable onSaveInstanceState()
public void onRestoreInstanceState(android.os.Parcelable state)
public boolean canScrollHorizontally()
getOrientation() is HORIZONTALpublic boolean canScrollVertically()
getOrientation() is VERTICALpublic int getOrientation()
HORIZONTAL or VERTICALsetOrientation(int)public void setOrientation(int orientation)
orientation - HORIZONTAL or VERTICALpublic int getMaxVisibleItemCount()
DETERMINE_BY_MAX_AND_MIN means it haven't been set now
And it will use maxRemoveOffset() and minRemoveOffset() to handle the rangepublic void setMaxVisibleItemCount(int mMaxVisibleItemCount)
DETERMINE_BY_MAX_AND_MIN means it haven't been set now
And it will use maxRemoveOffset() and minRemoveOffset() to handle the rangemMaxVisibleItemCount - Max visible item countpublic boolean isIntegerDy()
mIntegerDypublic void setIntegerDy(boolean mIntegerDy)
mIntegerDypublic boolean getReverseLayout()
setReverseLayout(boolean)public void setReverseLayout(boolean reverseLayout)
For horizontal layouts, it depends on the layout direction.
When set to true, If androidx.recyclerview.widget.RecyclerView is LTR, than it will
layout from RTL, if androidx.recyclerview.widget.RecyclerView} is RTL, it will layout
from LTR.
public void smoothScrollToPosition(RecyclerView recyclerView,
RecyclerView.State state,
int position)
public android.graphics.PointF computeScrollVectorForPosition(int targetPosition)
public void onLayoutChildren(RecyclerView.Recycler recycler,
RecyclerView.State state)
public int getTotalSpaceInOther()
public void onLayoutCompleted(RecyclerView.State state)
protected void setUp()
public void onAdapterChanged(RecyclerView.Adapter oldAdapter,
RecyclerView.Adapter newAdapter)
public void scrollToPosition(int position)
public int computeHorizontalScrollOffset(RecyclerView.State state)
public int computeVerticalScrollOffset(RecyclerView.State state)
public int computeHorizontalScrollExtent(RecyclerView.State state)
public int computeVerticalScrollExtent(RecyclerView.State state)
public int computeHorizontalScrollRange(RecyclerView.State state)
public int computeVerticalScrollRange(RecyclerView.State state)
public int scrollHorizontallyBy(int dx,
RecyclerView.Recycler recycler,
RecyclerView.State state)
public int scrollVerticallyBy(int dy,
RecyclerView.Recycler recycler,
RecyclerView.State state)
protected int calItemLeft(android.view.View itemView,
float targetOffset)
protected int calItemTop(android.view.View itemView,
float targetOffset)
protected float maxRemoveOffset()
layoutItems(RecyclerView.Recycler)protected float minRemoveOffset()
layoutItems(RecyclerView.Recycler)protected float propertyChangeWhenScroll(android.view.View itemView)
protected float getDistanceRatio()
public int getCurrentPosition()
public int getOffsetToCenter()
public void setOnPageChangeListener(OverFlyingLayoutManager.OnPageChangeListener onPageChangeListener)
public void setInfinite(boolean enable)
public boolean getInfinite()
public void setSmoothScrollbarEnabled(boolean enabled)
When smooth scrollbar is disabled, the position and size of the scrollbar thumb is based solely on the number of items in the mAdapter and the position of the visible items inside the mAdapter. This provides a stable scrollbar as the user navigates through a list of items with varying widths / heights.
enabled - Whether or not to enable smooth scrollbar.setSmoothScrollbarEnabled(boolean)public void setEnableBringCenterToFront(boolean bringCenterToTop)
public boolean getEnableBringCenterToFront()
public boolean getSmoothScrollbarEnabled()
setSmoothScrollbarEnabled(boolean)