I am using Recyclerview with CardView. I am aware how to control speed on list view. But not for Recyclerview.
I searched a lot in found class name SmoothScroll. How
Simply implement smoothScrollToPosition() of your LinearLayoutManager:
LinearLayoutManager layoutManager = new LinearLayoutManager(this) {
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
LinearSmoothScroller smoothScroller = new LinearSmoothScroller(this) {
private static final float SPEED = 300f;// Change this value (default=25f)
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return SPEED / displayMetrics.densityDpi;
}
};
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
}
};