I want to use a bounce effect on a RecyclerView
. A bounce effect whenever I overscroll the content...
Does there exist a library or example for it?
I want to use a bounce effect on a RecyclerView
. A bounce effect whenever I overscroll the content...
Does there exist a library or example for it?
I also couldn't find any library that supports the bounce effect for RecyclerView. Eventually I ended up implementing a new library by myself. Check out my library overscroll-bouncy-android. . It currently supports RecyclerView with LinearLayoutManager. I'm also working on ListView and ScrollView.
To use my library:
Step 1:
dependencies {
compile 'com.chauthai.overscroll:overscroll-bouncy:0.1.0'
}
Step 2:
<com.chauthai.overscroll.RecyclerViewBouncy
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
You can use this library https://github.com/EverythingMe/overscroll-decor So, you need to create your own ScrollDecorAdapter like this
public class CustomRecyclerViewOverScrollDecorAdapter extends RecyclerViewOverScrollDecorAdapter {
RecyclerView mRecyclerView;
public CustomRecyclerViewOverScrollDecorAdapter(RecyclerView recyclerView) {
super(recyclerView);
mRecyclerView = recyclerView;
}
@Override
public boolean isInAbsoluteEnd() {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
if (linearLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
return !mRecyclerView.canScrollHorizontally(1);
} else {
return !mRecyclerView.canScrollVertically(1);
}
}
}
And now in your fragment/activity use
CustomVerticalOverScrollDecorator overScrollDecorator =
new CustomVerticalOverScrollDecorator(new CustomRecyclerViewOverScrollDecorAdapter(yourRecyclerView));
Where CustomVerticalOverScrollDecorator smth like this
public class CustomVerticalOverScrollDecorator extends VerticalOverScrollBounceEffectDecorator {
public CustomVerticalOverScrollDecorator(IOverScrollDecoratorAdapter viewAdapter) {
this(viewAdapter, DEFAULT_TOUCH_DRAG_MOVE_RATIO_FWD, DEFAULT_TOUCH_DRAG_MOVE_RATIO_BCK, DEFAULT_DECELERATE_FACTOR);
}
public CustomVerticalOverScrollDecorator(IOverScrollDecoratorAdapter viewAdapter, float touchDragRatioFwd, float touchDragRatioBck, float decelerateFactor) {
super(viewAdapter, touchDragRatioFwd, touchDragRatioBck, decelerateFactor);
// Some setup on the view itself.
}
}