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.
I've faced the same issue and found a workaround, which is to use the smoothScrollToPosition in layout manager. This method triggers the scroll listener. So basically this is what I use to have:
recyclerView.scrollToPosition(recyclerAdapter.getItemCount() - 1);
and now I've changed to this:
recyclerView.getLayoutManager().smoothScrollToPosition(recyclerView, null, recyclerAdapter.getItemCount() - 1);
and it's working fine for me.
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