我想在recyclerview
中禁用垂直滚动(因为它在nestedscrollview
中并且没有“正常”行为)。但是在添加onInterceptTouchEvent
之后,我的recyclerview
无法“平滑地”滚动(我的意思是,我无法滚动不可见的事件,只能滚动当前的可见事件)。该如何解决?
specialDiscountsCategoriesList.layoutManager = LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false)
specialDiscountsCategoriesList.isNestedScrollingEnabled = false
specialDiscountsCategoriesList.setHasFixedSize(false)
specialDiscountsCategoriesList.addOnItemTouchListener(object : RecyclerView.OnItemTouchListener {
override fun onTouchEvent(rv: RecyclerView?, e: MotionEvent?) {
}
override fun onInterceptTouchEvent(rv: RecyclerView?, e: MotionEvent?): Boolean {
when (e?.action) {
MotionEvent.ACTION_UP, MotionEvent.ACTION_DOWN -> {
specialDiscountsCategoriesList.requestDisallowInterceptTouchEvent(false)
return true
}
}
return false
}
override fun onRequestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
}