turing-tech / MaterialScrollBar

An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
Apache License 2.0
781 stars 126 forks source link

Is there a way to get and set the Y position of the handle? #102

Closed nicoqueijo closed 6 years ago

nicoqueijo commented 7 years ago

I am implementing this library in my recyclerview and when the user exits the activity I save the index of the adapter in sharedpreferences so I can position the recyclerview in that index when they restart the activity. However, the handle of the scroll bar is always placed at the beginning (notice handle on gif). I noticed the MaterialScrollBar class has a Handle field but it is not public so I can't access it from my DragScrollBar object. How can I restore the position of the handle?

Alt Text

jooleeanh commented 6 years ago

I have the same issue, it'd be nice to have a .scrollToPosition(int position) method. Unfortunately, .scrollTo(int x, int y) seems to displace the scroll bar entirely instead of moving the handle.

turing-tech commented 6 years ago

The reason there is no .scrollToPosition() is because ideally the scroll bar should always be at the proper position with regard to the recyclerView. I have verified that this does not occur when .scrollToPosition() is called on the RV. I'll see what I can do to fix this.