RecyclerView and NestedScrollView with physics-based bouncy overscroll effect

RecyclerView and NestedScrollView with physics-based bouncy overscroll effect

Add IOS-like overscroll animation to your scrolling views using SpringAnimation.

Currently includes BouncyRecyclerView and BouncyNestedScrollView.

Gradle
Add it in your root build.gradle at the end of repositories:

allprojects {
repositories {

maven { url ‘https://jitpack.io’ }
}
}

In your app module build.gradle, add dependency for recyclerview and bouncy:

dependencies {
implementation ‘androidx.recyclerview:recyclerview:1.2.1’
implementation ‘com.github.valkriaine:Bouncy:2.1’
}

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 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:

recycler_view.setAdapter(myAdapter);
recycler_view.setLayoutManager(new LinearLayoutManager(context));
//recycler_view.setLayoutManager(new GridLayoutManager(context, 3));
Orientation
1.8 version added support for both vertical scrolling and horizontal bounce animation

When you set the LayoutManager, BouncyRecyclerView will automatically detect the orientation of the layout.

recycler_view.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
If the bounce animation is incorrect, you can also manually set the animation orientation:

recycler_view.setOrientation(LinearLayoutManager.VERTICAL);
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
recyclerview_damping_ratio and recyclerview_stiffness please refer to damping ratio and stiffness

Set in code:

recycler_view.setFlingAnimationSize(0.3f);
recycler_view.setOverscrollAnimationSize(0.3f);
recycler_view.setDampingRatio(Bouncy.DAMPING_RATIO_HIGH_BOUNCY);
recycler_view.setStiffness(Bouncy.STIFFNESS_HIGH);
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):

Read More
Share this on knowasiak.com to discuss with people on this topicSign up on Knowasiak.com now if you’re not registered yet.

Related Articles

What’s recent in Emacs 28.1?

By Mickey Petersen It’s that time again: there’s a new major version of Emacs and, with it, a treasure trove of new features and changes.Notable features include the formal inclusion of native compilation, a technique that will greatly speed up your Emacs experience.A critical issue surrounding the use of ligatures also fixed; without it, you…

Responses

Your email address will not be published. Required fields are marked *