Bouncy
Add IOS-like overscroll animation to your scrolling views using SpringAnimation.
Currently includes BouncyRecyclerView and BouncyNestedScrollView.
Add Bouncy to your project
In your app module build.gradle:
dependencies {
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.factor:bouncy:1.61'
}
(androidx.recyclerview is required for BouncyRecyclerView to work)
BouncyNestedScrollView
NestedScrollView with bouncy overscroll effect, currently only supports vertical scrolling.
Achieved by overriding the default EdgeEffect
Usage:
Use as normal NestedScrollView. Place it in your layout:
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.
BouncyRecyclerView
BouncyRecyclerView adds overscroll effect to RecyclerView and supports drag & drop and swiping gestures
Usage:
Use as normal RecyclerView. Place it in your layout:
set up layout manager and adapter. Theoratically supports any LayoutManager:
Customization
recyclerview_fling_animation_size
specifies the magnitude of overscroll effect for fling, default is 0.5 if no value is given
recyclerview_overscroll_animation_size
specifies the magnitude of overscroll effect for drag, default is 0.5 if no value is given
allow_drag_reorder
and allow_item_swipe
are set to false by default. If you would like to enable these features, simply set them to true.
Spring customization (Bouncy 1.6 and above)
recyclerview_damping_ratio
and recyclerview_stiffness
please refer to damping ratio and stiffness
Set in code:
A known issue is when customizing spring properties, items close to the edges of the screen may be clipped since the current implementation animates the Y translation of the whole recyclerview. A workaround is to place the BouncyRecyclerView
inside a NestedScrollView
(not necessarily BouncyNestedScrollView
):
Drag & drop
Drag & drop does not work out of the box.
For drag & drop or swipe gestures to work, make your adapter extend BouncyRecyclerView.Adapter
and add constructor matching parent.
(If your adapter does not extend BouncyRecyclerView.Adapter, BouncyRecyclerView will simply disable the gestures)
Also refer to the Kotlin example