recycview.addOnScrollListener(object:RecyclerView.OnScrollListener(){
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
if(customerrecycview.canScrollVertically(1)){
Log.i("info", "direction 1: true")
}else {
Log.i("info", "direction 1: false")
//滑动到底部
}
if(customerrecycview.canScrollVertically(-1)){
Log.i("info", "direction -1: true")
}else {
Log.i("info", "direction -1: false")
//滑动到顶部
}
}
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
}
})
recycview 判断 是否滑动到顶部或底部
最新推荐文章于 2022-04-25 00:16:33 发布