GithubHelp home page GithubHelp logo

jahirfiquitiva / recyclerview-fastscroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from timusus/recyclerview-fastscroll

1.0 1.0 1.0 1.83 MB

A simple FastScroller for Android's RecyclerView

License: Other

Java 100.00%

recyclerview-fastscroll's Introduction

RecyclerView-FastScroll

Maven Central API License Build Status

A simple FastScroller for Android's RecyclerView.

Supports vertical RecyclerViews using either LinearLayoutManager or GridLayoutManager (including multiple spans).

The style is loosely based on the ListView FastScroller from whatever the last version of Lollipop was. This library borrows heavily from Google's Launcher3 FastScroller

Screenshot

Gradle

compile 'com.simplecityapps:recyclerview-fastscroll:2.0.1'

Usage

You must use FastScrollRecyclerView as your base RecyclerView. See the sample project if you're having trouble.

Via xml:

<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
    android:id="@+id/recycler"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:fastScrollPopupBgColor="@color/colorAccent"
    app:fastScrollPopupTextColor="@android:color/primary_text_dark"
    app:fastScrollThumbColor="@color/colorAccent" />

To display the FastScrollPopup, your adapter must implement FastScrollRecyclerView.SectionedAdapter and override getSectionName().

If you need to know when fast-scrolling starts or stops, you can attach an OnFastScrollStateChangedListener to the FastScrollRecyclerView.

Varying Row Heights

By default, FastScrollRecyclerView assumes that all items in the adapter have the same height. If your adapter has item views with different heights, then you should make your adapter implement the MeasurableAdapter interface and override getViewTypeHeight() โ€“ otherwise the scroll thumb may not appear in the correct position and scrolling may be inconsistent.

getViewTypeHeight() returns the height of a single view of a given type in pixels. The height of each view must be fixed and constant between all instances of a view type. Because the implementor is responsible for computing this value before views are laid out, this is not suitable for view types where the height of a view is determined by a variable number of lines of text that the item consumes.

Currently, MeasurableAdapter only works with LinearLayoutManager. Using MeasurableAdapter with a GridLayoutManager that has more than one span will cause the scrollbar thumb to reach the bottom of the list before the halfway point on the scrollbar's background.

Customisation

You can enable/disable autohide using the fastScrollAutoHide & fastScrollAutoHideDelay attributes in xml:

 <com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
     app:fastScrollAutoHide="true"
     app:fastScrollAutoHideDelay="1500"
     ...

Or programmatically via setAutoHideDelay(int hideDelay) and setAutoHideEnabled(boolean autoHideEnabled)

The following can be styled via xml:

  • Popup background
  • Popup text
  • Popup background size
  • Popup text size
  • Track width and background
  • Thumb width and color
  • Popup position
  • Popup text vertical alignment mode
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
    app:fastScrollPopupBgColor="@color/colorAccent"
    app:fastScrollPopupTextColor="@android:color/primary_text_dark"
    app:fastScrollPopupTextSize="56sp"
    app:fastScrollPopupBackgroundSize="88dp"
    app:fastScrollThumbColor="@color/colorAccent"
    app:fastScrollThumbWidth="6dp"
    app:fastScrollTrackColor="#1f000000"
    app:fastScrollTrackWidth="8dp"
    app:fastScrollPopupPosition="adjacent"
    app:fastScrollPopupTextVerticalAlignmentMode="fontMetrics"/>
    ...

Or programmatically via

  • setThumbColor(@ColorInt int color)
  • setTrackColor(@ColorInt int color)
  • setPopupBgColor(@ColorInt int color)
  • setPopupTextColor(@ColorInt int color)
  • setPopupTextSize(int size)
  • setPopupPosition(@FastScroller.FastScrollerPopupPosition int position)

You can enable/disable fast-scrolling via:

<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
    app:fastScrollThumbEnabled="false"
    ...

Or programmatically via setFastScrollThumbEnabled(boolean enabled)

recyclerview-fastscroll's People

Contributors

andrewbailey avatar bcsl avatar ebomike avatar g00fy2 avatar geometer avatar huikaihoo avatar jahirfiquitiva avatar kabouzeid avatar mathieupost avatar nadavfima avatar nammari avatar timusus avatar vfishv avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

mveroukis

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.