Tag: 拉到刷新

检查RecyclerView是否滚动(findFirstCompletelyVisibleItemPosition不起作用)

我如何检查回收站视图是否滚动到其顶部 (列表的开始),而不使用findFirstCompletelyVisibleItemPosition ? 说明:我不能使用这种方法,因为RecyclerView上的项目很大,有时永远不会“完全可见”,所以方法将返回-1( RecyclerView.NO_POSITION ) 我只需要知道这一点,只有当回收站视图达到顶峰时才会触发一个动作。 val manager = timelineRecyclerView?.layoutManager as StaggeredGridLayoutManager val visibles = manager.findFirstCompletelyVisibleItemPositions(null) 解决:包括一些代码来帮助 timelineRecyclerView.addOnScrollListener(object:RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView:RecyclerView, newState:Int) { super.onScrollStateChanged(recyclerView, newState) } override fun onScrolled(recyclerView:RecyclerView, dx:Int, dy:Int) { super.onScrolled(recyclerView, dx, dy) currentTimelinePosition += dy Log.wtf("position", currentTimelinePosition.toString()) //if the timeline position is on its start, allow swipe and refresh swipeLayout.isEnabled […]