Giter Site home page Giter Site logo

sajjadintel / overflow-pager-indicator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from intik/overflow-pager-indicator

1.0 1.0 0.0 594 KB

Simple paging indicator widget with pager dataset ovewflow effect à la Instagram behavior

License: MIT License

Java 100.00%

overflow-pager-indicator's Introduction

Overflow Pager Indicator widget

Download license

Simple widget for recycler view - displaying dots indicators of currently selected page - with some fancy animation when dataset is large.

Large dataset displays only fixed amount of dots centered around currently selected page with a nice little scaling animation of indicators on the edges. Provides fluent animation of selecting new page.

Small dataset displays classic dot indicators line with currently selected page highlighted.

RecyclerView should be configured with snapping to pages vie PagerSnapHelper subclass ~ simulates behavior of classic ViewPager

Widget preview

✔️ Overflowed indicators ❌ Classic confusing indicators
Widget effect animation preview Classic

Disclaimer: Having too many pages in recycler means that user needs to swipe a lot. Different layout/ui may be more user friendly.

Usage

Gradle dependency

In your gradle add dependency:

compile "cz.intik:overflow-pager-indicator:$latestVersion"

Layout

Some layout with RecyclerView and OverflowPagerIndicator

<FrameLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   >

   <android.support.v7.widget.RecyclerView
      android:id="@+id/recycler_view"
      android:layout_width="match_parent"
      android:layout_height="120dp"
      />

   <cz.intik.overflowindicator.OverflowPagerIndicator
      android:id="@+id/view_pager_indicator"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center_horizontal|bottom"
      />

</FrameLayout>

Code

Attach OverflowPagerIndicator (usually after LayoutManager and Adapter setup) to RecyclerView - for listening to dataset changes

overflowPagerIndicator.attachToRecyclerView(recyclerView);

Attach SimpleSnapHelper to recycler view which will change selected page in indicator view as items in recycler view are snapped

SimpleSnapHelper snapHelper = new SimpleSnapHelper(overflowPagerIndicator);
snapHelper.attachToRecyclerView(recyclerView);

Or use any other implementation of PagerSnapHelper or even some custom logic which will call:

OverflowPagerIndicator#onPageSelected(int position)

overflow-pager-indicator's People

Contributors

intik avatar sajjadintel avatar

Stargazers

 avatar

Watchers

 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.