How to show text that moves along scrollbar using RecyclerView?

By | July 13, 2018
Questions:

I’m using Recylerview and want to show list like this https://i.stack.imgur.com/kMh1q.png
I’ve tried to enable fastScroll in xml as below however it only can change thumb and track of Recyclerview and can’t show the text as I expected.

 <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical"
            app:fastScrollEnabled="true"
            app:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
            app:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
            app:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
            app:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>

I’m looking for attributes similar to fastScrollTextColor and fastScrollPreviewBackgroundRight in Recyclerview to shows text along scrollbar like in this example http://androidopentutorials.com/android-listview-fastscroll/ but it seem that RecyclerView doesn’t support those
In that example uses ListView instead and these attributes can be declare in as styles of ListView

<style name="FastScrollStyle" parent="AppBaseTheme">
        <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item>
        <item name="android:fastScrollOverlayPosition">atThumb</item>
        <item name="android:fastScrollTextColor">@color/apptheme_color</item>
        <item name="android:fastScrollTrackDrawable">@drawable/fastscroll_thumb_pressed_holo</item>
        <item name="android:fastScrollPreviewBackgroundRight">@drawable/bg_default_focused_holo_light</item>
    </style>

Anyone can help me do so with RecyclerView? Thanks!

Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *