Android how can I get current positon on recyclerview that user scrolled to item

You are trying to get the info on the wrong object. It is not the RecyclerView nor the Adapter responsibility but the RecyclerView’s LayoutManager.

Instead of the generic ViewTreeObserver.OnScrollChangedListener() I would recommend to add instead the RecyclerView.OnScrollListener and use the onScrollStateChanged(RecyclerView recyclerView, int newState) callback which gives you the newState, you should use SCROLL_STATE_IDLE to fetch its position. Meaning:

yourRecyclerView.getLayoutManager().findFirstVisibleItemPosition();

As Rik van Velzen pointed out, you probably need to cast your
LayoutManager to a LinearLayoutManager or GridLayoutManager
(you have to cast to the correct type you are using) to access these
findVisibleXXXX() methods.

On said callback method. Hope I made this clear enough for your, you can find documentation on the classes here:

RecyclerView.OnScrollListener

yigit’s (Google) response on visible positions

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)