RecyclerView scrollToPosition not trigger scrollListener

前端 未结 8 2305
予麋鹿
予麋鹿 2021-02-01 03:35

I\'m using RecyclerView, with ScrollListener:

mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener()
{
        @Override
        public void onScr         


        
8条回答
  •  耶瑟儿~
    2021-02-01 03:57

    This is a known issue. It is caused by the fact that RecyclerView does not know how LayoutManager will handle the scroll or if it will handle it at all.

    In the next release, you'll receive a call to onScrolled if first and or last child position changes after a layout (which is generally the result of calling scroll to position).

    Unfortunately, dx and dy will be 0 because RecyclerView does not really know how much layout manager did scroll to handle scrollTo request. Alternatively, you can also use the the ViewTreeObserver's scroll callback.

提交回复
热议问题