|
1 | | -# overflow-pager-indicator |
| 1 | +# Overflow Pager Indicator widget |
2 | 2 |
|
3 | | -Simple paging indicator widget with pager dataset ovewflow effect à la Instagram behavior |
| 3 | +Overflow Pager Indicator is a simple widget for recycler view - displaying dots indicators of |
| 4 | +currently selected page - with some fancy animation when dataset is large. |
| 5 | + |
| 6 | +When the dataset in recycler view is large it displays only fixed amount of dots centered around |
| 7 | + currently selected page with a nice little scaling animation of indicators on the edges. Provides |
| 8 | + fluent animation of selecting new page. |
| 9 | + |
| 10 | +If dataset in recycler view is small it displays classic dot indicators line with currently selected |
| 11 | +page highlighted. |
| 12 | + |
| 13 | +RecyclerView should be configured with snapping to pages vie PagerSnapHelper subclass ~ simulates |
| 14 | +behavior of classic ViewPager |
| 15 | + |
| 16 | +# Usage |
| 17 | + |
| 18 | +## Gradle dependency |
| 19 | + |
| 20 | +In your gradle add dependency: |
| 21 | + |
| 22 | +```gradle |
| 23 | +compile 'cz.intik:overflow-pager-indicator:1.1.1' |
| 24 | +``` |
| 25 | + |
| 26 | +## Layout |
| 27 | + |
| 28 | +Some layout with RecyclerView and OverflowPagerIndicator |
| 29 | + |
| 30 | +```xml |
| 31 | +<FrameLayout |
| 32 | + android:layout_width="match_parent" |
| 33 | + android:layout_height="wrap_content" |
| 34 | + > |
| 35 | + |
| 36 | + <android.support.v7.widget.RecyclerView |
| 37 | + android:id="@+id/recycler_view" |
| 38 | + android:layout_width="match_parent" |
| 39 | + android:layout_height="120dp" |
| 40 | + /> |
| 41 | + |
| 42 | + <cz.intik.overflowindicator.OverflowPagerIndicator |
| 43 | + android:id="@+id/view_pager_indicator" |
| 44 | + android:layout_width="wrap_content" |
| 45 | + android:layout_height="wrap_content" |
| 46 | + android:layout_gravity="center_horizontal|bottom" |
| 47 | + /> |
| 48 | + |
| 49 | +</FrameLayout> |
| 50 | +``` |
| 51 | + |
| 52 | +## Code |
| 53 | + |
| 54 | +Attach |
| 55 | +[OverflowPagerIndicator](https://github.com/intik/overflow-pager-indicator/blob/docs-update/library/src/main/java/cz/intik/overflowindicator/OverflowPagerIndicator.java) |
| 56 | +(usually after LayoutManager and Adapter setup) to |
| 57 | +[RecyclerView](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html) |
| 58 | +\- for listening to dataset changes |
| 59 | + |
| 60 | +```java |
| 61 | +overflowPagerIndicator.attachToRecyclerView(recyclerView); |
| 62 | +``` |
| 63 | + |
| 64 | +Attach |
| 65 | +[SimpleSnapHelper](https://github.com/intik/overflow-pager-indicator/blob/docs-update/library/src/main/java/cz/intik/overflowindicator/SimpleSnapHelper.java) |
| 66 | +to recycler view which will change selected page in indicator view as items in recycler |
| 67 | +view are snapped |
| 68 | + |
| 69 | +```java |
| 70 | +SimpleSnapHelper snapHelper = new SimpleSnapHelper(overflowPagerIndicator); |
| 71 | +snapHelper.attachToRecyclerView(recyclerView); |
| 72 | +``` |
| 73 | + |
| 74 | +Or use any other implementation of |
| 75 | +[PagerSnapHelper](https://developer.android.com/reference/android/support/v7/widget/PagerSnapHelper.html "Android Developers - docs - PagerSnapHelper") |
| 76 | +or even some custom logic which will call: |
| 77 | + |
| 78 | +```java |
| 79 | +OverflowPagerIndicator#onPageSelected(int position) |
| 80 | +``` |
0 commit comments