|
| 1 | +#ECardFlow |
| 2 | + |
| 3 | +ECardFlow, A custom ViewPager for multiple card flow system.designed by [Leo Leung](https://ios.uplabs.com/posts/multiple-card-flow |
| 4 | +) |
| 5 | +ECardFlow, 一个用于复数卡片滑动与展开效果的ViewPager控件,设计原型出自[Leo Leung](https://ios.uplabs.com/posts/multiple-card-flow |
| 6 | +) |
| 7 | + |
| 8 | +#Preview |
| 9 | + |
| 10 | + |
| 11 | +#Usage |
| 12 | + |
| 13 | +Step 1. Add the JitPack repository to your build file |
| 14 | + |
| 15 | + allprojects { |
| 16 | + repositories { |
| 17 | + ... |
| 18 | + maven { url "https://jitpack.io" } |
| 19 | + } |
| 20 | + } |
| 21 | + |
| 22 | +Step 2. Add the dependency |
| 23 | + |
| 24 | + dependencies { |
| 25 | + compile 'com.github.codeestX:ECardFlow:v1.0.0' |
| 26 | + } |
| 27 | + |
| 28 | +Step 3. Just use it as a ViewPager |
| 29 | + |
| 30 | + <moe.codeest.ecardflow.ECardFlow |
| 31 | + android:id="@+id/ecardflow" |
| 32 | + android:layout_width="280dp" |
| 33 | + android:layout_height="match_parent" |
| 34 | + app:expandMode="slide_up" |
| 35 | + app:expandTime="700" |
| 36 | + app:switchSpeed="6" |
| 37 | + app:preloadPageNum="3" |
| 38 | + app:maxRotateY="5"> |
| 39 | + |
| 40 | +* Only support fragment as each page |
| 41 | +* For best performance, giving ECardFlow's parent view an attr`android:clipChildren="false"`,and do `NOT` set ECardFlow's width as`match_parent` |
| 42 | +* See DemoProject for more details |
| 43 | + |
| 44 | +Attrs: |
| 45 | + |
| 46 | + <declare-styleable name="attr"> |
| 47 | + <!-- Page switching speed, more big,more slowly, default 6 --> |
| 48 | + <attr name="switchSpeed" format="integer" /> |
| 49 | + |
| 50 | + <!-- Page expand time, default 700ms --> |
| 51 | + <attr name="expandTime" format="integer" /> |
| 52 | + |
| 53 | + <!-- Page expand mode, click or slide up to expand, default slide_up --> |
| 54 | + <attr name="expandMode"> |
| 55 | + <enum name="slide_up" value="10" /> |
| 56 | + <enum name="click" value="11" /> |
| 57 | + </attr> |
| 58 | + |
| 59 | + <!-- The number of pages outside the screen, default 3 --> |
| 60 | + <attr name="preloadPageNum" format="integer" /> |
| 61 | + |
| 62 | + <!-- The shortest sliding distance to trigger the switch, default context.getScaledTouchSlop() --> |
| 63 | + <attr name="touchSlop" format="integer" /> |
| 64 | + |
| 65 | + <!-- The maximum angle of rotation, default 5 --> |
| 66 | + <attr name="maxRotateY" format="integer" /> |
| 67 | + </declare-styleable> |
| 68 | + |
| 69 | +Java Code: |
| 70 | + |
| 71 | + mEcardflow.gotoNext(); |
| 72 | + |
| 73 | + mEcardflow.gotoLast(); |
| 74 | + |
| 75 | + mEcardflow.expand(); |
| 76 | + |
| 77 | + mEcardflow.shrink(); |
| 78 | + |
| 79 | + mEcardflow.setSwitchSpeed(rate); |
| 80 | + |
| 81 | + mEcardflow.setTouchSlop(slop); |
| 82 | + |
| 83 | + mEcardflow.setExpandTime(time); |
| 84 | + |
| 85 | + mEcardflow.setOnExpandStateListener(new ECardFlow.OnExpandStateListener() { |
| 86 | + @Override |
| 87 | + public void onExpand(View page, int position) { |
| 88 | + |
| 89 | + } |
| 90 | + |
| 91 | + @Override |
| 92 | + public void onShrink(View page, int position) { |
| 93 | + |
| 94 | + } |
| 95 | + }); |
| 96 | + |
| 97 | +#License |
| 98 | + |
| 99 | + MIT Copyright (c) 2017 codeestX |
0 commit comments