Is there a simple way to scroll back to latest entries in a RecyclerView only when latest entries are no longer visible (due to the user scrolling away)?

Ideally, I wish if there is a listener that can be put on the RecyclerView's Adapter that is called only when an entry is in a given position (e.g., say an entry in position adapter.itemCount - 1 stops being visible).

1

There are 1 best solutions below

0
Sidharth Shambu On

I don't think there is a method that gets called only when the user-defined position goes out of view.

You can use the adapter's onViewDetachedFromWindow method. You get the view holder as the function parameter and based on holder.getAbsoluteAdapterPosition(), you can probably show or hide the "Jump to latest button".