Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

InterestingAndroid/PathLayoutManager

Repository files navigation

RecyclerView的LayoutManager,轻松实现各种炫酷、特殊效果,再也不怕产品经理为难!

使用方式:

添加依赖:

implementation 'com.wuyr:pathlayoutmanager:1.0.1'

APIs:

Method Description
updatePath(Path path) 更新Path
setItemOffset(int itemOffset) 设置Item间距 (单位: px)
setOrientation(int orientation) 设置滑动方向:
RecyclerView.HORIZONTAL (水平滑动)
RecyclerView.VERTICAL (垂直滑动)
setScrollMode(int mode) 设置滚动模式:
SCROLL_MODE_NORMAL (普通模式)
SCROLL_MODE_OVERFLOW (允许溢出)
SCROLL_MODE_LOOP (无限循环)
setItemDirectionFixed(boolean isFixed) 设置Item是否保持垂直
setAutoSelect(boolean isAutoSelect) 设置是否开启自动选中效果
setAutoSelectFraction(float position) 设置自动选中的目标落点 (0~1)
setFlingEnable(boolean enable) 设置惯性滚动是否开启
setCacheCount(int count) 设置Item缓存个数
setItemScaleRatio(float... ratios) 设置平滑缩放比例
ratios: 缩放比例, 数组长度必须是双数,
偶数索引表示要缩放的比例
奇数索引表示在路径上的位置 (0~1)
奇数索引必须要递增,即越往后的数值应越大
例如:
setItemScaleRatio(0.8, 0.5)
表示在路径的50%处把Item缩放到原来的80%
setItemScaleRatio(0, 0, 1, 0.5, 0, 1)
表示在起点处的Item比例是原来的0%,在路径的50%处会恢复原样
到路径终点处会缩小到0%
scrollToPosition(int position) 将目标Item滚动到自动选中的落点(setAutoSelectFraction)
例如 setAutoSelectFraction(0) 则滚动到Path的起点处
若为1,则滚动到路径终点处,0.6则路径的60%处 (默认: 0.5)
smoothScrollToPosition(int position) 同上,此方法为平滑滚动,即选中时会播放动画
动画时长通过 setFixingAnimationDuration 方法来设置
setFixingAnimationDuration(long duration) 设置自动选中后的选中动画时长
setOnItemSelectedListener(Listener listener) 设置Item被选中后的监听器 (需开启自动选中才生效)

使用示例:

 mPathLayoutManager = new PathLayoutManager(path, itemOffset);
 mRecyclerView.setLayoutManager(mPathLayoutManager);

Demo下载: app-debug.apk

效果:

preview preview preview preview preview preview preview preview

About

RecyclerView的LayoutManager,轻松实现各种炫酷、特殊效果,再也不怕产品经理为难!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%

AltStyle によって変換されたページ (->オリジナル) /