Which RecyclerView
function returns max Scroll offset?
I need to determine, can i hide footer of Activity
or not, by RecyclerView
scroll.
getHeight(); recyclerView. smoothScrollToPosition(height); recyclerView. postDelayed(new Runnable() { public void run() { recyclerView. smoothScrollToPosition(0); } },200);
To be able to scroll through a vertical list of items that is longer than the screen, you need to add a vertical scrollbar. Inside RecyclerView , add an android:scrollbars attribute set to vertical .
In order to detect that the user has scrolled to the end of the RecyclerView, we need to implement OnScrollListener() on the RecyclerView.
The asked function is recyclerView.computeVerticalScrollRange();
This function returns true if end of scrolling reached.
static private boolean isMaxScrollReached(RecyclerView recyclerView) {
int maxScroll = recyclerView.computeVerticalScrollRange();
int currentScroll = recyclerView.computeVerticalScrollOffset() + recyclerView.computeVerticalScrollExtent();
return currentScroll >= maxScroll;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With