RecyclerView-FastScroll

repository·master·Indexed 23 days ago

https://github.com/timusus/recyclerview-fastscroll

An Android library providing a fast-scrolling UI for RecyclerView, similar to the ListView FastScroller. It features a FastScrollRecyclerView view, support for section names via SectionedAdapter, and height handling for varying row heights through MeasurableAdapter. The library allows for extensive customization of the thumb, track, and popup appearance via XML attributes or programmatic methods.

Tokens
1.3K
Snippets
4
Records
8
Agent score
30%

What's inside RecyclerView-FastScroll

  1. Handle varying row heights with MeasurableAdapter

    master

    By default, the library assumes all items have the same height. If your items have different heights, your adapter must implement the MeasurableAdapter interface and override getViewTypeHeight(). This method should return the height of a single view of a given type in pixels.

    Note:

    • The height for a view type must be fixed and constant. It is not suitable for views with variable text content (e.g., multi-line text).
    • MeasurableAdapter currently only works correctly with LinearLayoutManager. Using it with a GridLayoutManager that has more than one span may cause the thumb to reach the bottom of the list prematurely.
  2. Configure Autohide settings

    master

    You can control whether the fast scroll thumb automatically hides and how long it stays visible using the following methods:

    Via XML:

    • app:fastScrollAutoHide: boolean
    • app:fastScrollAutoHideDelay: integer (milliseconds)

    Programmatically:

    • setAutoHideEnabled(boolean autoHideEnabled)
    • setAutoHideDelay(int hideDelay)
    <com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
         app:fastScrollAutoHide="true"
         app:fastScrollAutoHideDelay="1500"
         ...
  3. Use FastScrollRecyclerView in XML

    master

    To use the fast scroller, replace your standard RecyclerView with com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView in your layout XML. You can configure basic styling directly via XML attributes.

    <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" />
  4. Customize FastScroll appearance

    master

    The library provides extensive customization options for the thumb, track, and popup via XML or programmatic calls.

    Available XML attributes:

    • app:fastScrollPopupBgColor (Popup background color)
    • app:fastScrollPopupTextColor (Popup text color)
    • app:fastScrollPopupTextSize (Popup text size)
    • app:fastScrollPopupBackgroundSize (Popup background size)
    • app:fastScrollThumbColor (Thumb color)
    • app:fastScrollThumbWidth (Thumb width)
    • app:fastScrollTrackColor (Track color)
    • app:fastScrollTrackWidth (Track width)
    • app:fastScrollPopupPosition (Popup position)
    • app:fastScrollPopupTextVerticalAlignmentMode (Popup text vertical alignment mode)

    Available Programmatic methods:

    • setThumbColor(@ColorInt int color)
    • setTrackColor(@ColorInt int color)
    • setPopupBgColor(@ColorInt int color)
    • setPopupTextColor(@ColorInt int color)
    • setPopupTextSize(int size)
    • setPopupPosition(@FastScroller.FastScrollerPopupPosition int position)
    <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"/>
        ...