control fling speed for recycler view

后端 未结 5 531
野的像风
野的像风 2021-02-07 18:02

I have a RecyclerView in which i have an image ,a few TextViews and 2 ImageButtons. I have 7-8 such rows to display in my Activity

5条回答
  •  野的像风
    2021-02-07 18:30

    I had the same problem. Here is the solution to slow down the fling.

            val maxFling=4000
            onFlingListener = object : RecyclerView.OnFlingListener() {
                override fun onFling(velocityX: Int, velocityY: Int): Boolean {
                    if (velocityY > maxFling) {
                        fling(velocityX, maxFling)
                        return true
                    } else if (velocityY < -maxFling) {
                        fling(velocityX, -maxFling)
                        return true
                    } else {
                        return false
                    }
    
                }
    
            }
    

提交回复
热议问题