我试图使用ItemTouchHelper在RecyclerView的项上实现滑动手势,但默认的滑动速度非常快,我需要稍微慢一点。如何控制滑动速度?
使用RecyclerView ItemTouchHelper,我正在尝试为recyclerview列表项实现弹簧类型行为,因为我想为我的应用程序构建“滑动回复”功能,但是ItemTouchHelper提供的滑动速度非常快,这对用户体验不好,所以是否有任何方法或解决方法可以减少ItemTouchHelper类中的滑动速度?
val swipeHelper =
ItemTouchHelper(
object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {
override fun onMove(
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder,
) = true
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {}
override fun onChildDraw(
canvas: Canvas,
recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
dX: Float,
dY: Float,
actionState: Int,
isCurrentlyActive: Boolean,
) {
super.onChildDraw(
canvas,
recyclerView,
viewHolder,
dX / 10,
dY,
actionState,
isCurrentlyActive
)
}
}
)
swipeHelper.attachToRecyclerView(rvList)