Closed RobbWatershed closed 4 years ago
Simply adding a scrollbar is very easy and can be done in xml like below.
<android.support.v7.widget.RecyclerView
...
android:scrollbars="vertical" />
But this only shows a scrollbar that shows the current scroll position, it cannot be touched or dragged to scroll through content. To add a scrollbar that can be dragged to scroll through content, fastScrollEnabled=true
needs to be added to the RecyclerView along with a few drawables for the scrollbar itself.
https://stackoverflow.com/questions/45370246/how-to-use-fastscrollenabled-in-recyclerview
The process is a little bit more involved than simply turning scrollbars on and while some libraries exist to implement this, they don't usually play well with other recyclerview helpers because they require you to use their own RecyclerView and Adapter subclass.
https://github.com/timusus/RecyclerView-FastScroll
Usually the best solution is to follow the stackoverflow guide above and create a subclass of RecyclerView which overrides computeVerticalScrollExtent()
, computeVerticalScrollOffset()
, and computeVerticalScrollRange()
so that the scrollbar doesn't become too small in very long lists.
...mainly to help users with a huge queue.