I'm using RecyclerView, with ScrollListener:
mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener()
{
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState)
{
super.onScrollStateChanged(recyclerView, newState);
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy)
{
super.onScrolled(recyclerView, dx, dy);
// Do my logic
}
});
When I scroll with the finger, the scroll listener triggered fine.
But when I scroll progrematically, like that:
mRecyclerView.scrollToPosition(LAST_POSITION);
The scroll listener is not triggered.
Please try with
LayoutManager.scrollToPosition()
may not work well, butLinearLayoutManager.scrollToPositionWithOffset()
will work. And similarlly GridLayoutManager as well.Or we have to write our custom way of implementation because RecyclerView doesn't know how LayoutManager scrolls the view.
Sometimes this does the trick