Android: Listview's bounce to scrollview

后端 未结 6 885
生来不讨喜
生来不讨喜 2021-02-02 00:33

Any way of adding ListView\'s bounce effect to regular scrollview? By bounce I mean the rubber band like effect when you hit the bottom of the list.

6条回答
  •  故里飘歌
    2021-02-02 00:52

    For anyone looking for the bounce effect on NestedScrollView, I have made a library: https://github.com/Valkriaine/Bouncy

    Usage:

    In your app module build.gradle:

       dependencies {
            implementation 'com.factor:bouncy:1.8'
    
            // if you want BouncyRecyclerView too, add implementation for recyclerview
            implementation 'androidx.recyclerview:recyclerview:1.1.0'
    
       }
    

    And use BouncyNestedScrollView as a normal NestedScrollView:

    
    
        
                
                ...
                ...
                ...
    
        
    
    
    

    fling_animation_size specifies the magnitude of overscroll effect for fling, default is 0.5 if no value is given.

    overscroll_animation_size specifies the magnitude of overscroll effect for drag, default is 0.5 if no value is given.

    Strongly suggest to keep both values lower than 5.

    BouncyNestedScrollView was modified based on the source code of NestedScrollView, so technically it should work with all existing customization options of NestedScrollView.

提交回复
热议问题