RecyclerView and NestedScrollView with physics-based bouncy overscroll effect

19
[favorite_button]
RecyclerView and NestedScrollView with physics-based bouncy overscroll effect
Advertisements

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’ }
}
}

Advertisements

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

Advertisements

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.

Advertisements

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:

Advertisements

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

Advertisements

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:

Advertisements

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.

Advertisements
Knowasiak
WRITEN BY

Knowasiak

Hey! look, i give tutorials to all my users and i help them!
Get Connected!
One of the Biggest Social Platform for Entrepreneurs, College Students and all. Come and join our community. Expand your network and get to know new people!

Discussion(s)

No comments yet
Knowasiak We would like to show you notifications so you don't miss chats & status updates.
Dismiss
Allow Notifications