Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android RecyclerView max scroll offset

Which RecyclerView function returns max Scroll offset?

I need to determine, can i hide footer of Activity or not, by RecyclerView scroll.

like image 865
Alpha Avatar asked Jul 16 '15 12:07

Alpha


People also ask

How can I control the scrolling speed of RecyclerView?

getHeight(); recyclerView. smoothScrollToPosition(height); recyclerView. postDelayed(new Runnable() { public void run() { recyclerView. smoothScrollToPosition(0); } },200);

How do I make my recycler view scrollable?

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 .

How do I know if my RecyclerView is scrolled to the bottom?

In order to detect that the user has scrolled to the end of the RecyclerView, we need to implement OnScrollListener() on the RecyclerView.


1 Answers

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;
}
like image 119
Alexander Skvortsov Avatar answered Oct 11 '22 18:10

Alexander Skvortsov