Git Product home page Git Product logo

pathlayoutmanager's Introduction

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

pathlayoutmanager's People

Contributors

wuyr avatar

Watchers

xiangyutian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.