Is there a way to get how far a user has scrolled on a recyclerView?

228 Views Asked by At

My question is anchored in my current objective of making a custom scrollbar to scroll various types of views (right now it's a RecyclerView). I decided to try and use a rotated SeekBar instead of multiple ImageViews because the SeekBar seemed easier to manipulate and work with, plus it bounds itself to the edges of the SeekBar, so boundary code isn't required on my end.

I set it up, and based on research into documentation and other forum posts online, I knew that I'd need however far the user has scrolled down divided by the maximum range the user can scroll. However, I don't know entirely how to get either of these values as accurately as possible. I tried using computeVerticalScrollOffset() / computeVerticalScrollRange() at first, since that seemed logically correct, but it didn't work and always returns 0. I've also tried keeping track of the value by adding an onScrollListener to the RecyclerView and incrementing a value based on the dy-value provided by the onScrolled() method in that listener... this also didn't work properly, and would fail rather often as well, depending on the scrolling behavior of the user.

Is there any way for me to get the distance scrolled, and the maximum possible scrollable distance? I've been trying to figure this (and the overarching scrollbar problem, which this is meant to be a solution to) out for nearly two weeks now, and all of my research has led to dead ends. I would greatly appreciate any advice or help that anyone here could offer on this.

0

There are 0 best solutions below