control fling speed for recycler view

后端 未结 5 613
野的像风
野的像风 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:31

    There is one RecyclerView method specifically designed to control the fling speed you only need to override it to achieve the friction/slowdown effect you mentioned in your question.

    One simple implementation you could try:

    @Override
    public boolean fling(int velocityX, int velocityY)
    {
    
         // if FLING_SPEED_FACTOR between [0, 1[ => slowdown 
         velocityY *= FLING_SPEED_FACTOR; 
    
         return super.fling(velocityX, velocityY);
    } 
    

提交回复
热议问题