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
I just simplifying Answer how to use it to control smooth scroll.
Create Class
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
public class CustomRecyclerView extends RecyclerView {
Context context;
public CustomRecyclerView(Context context) {
super(context);
this.context = context;
}
public CustomRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomRecyclerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean fling(int velocityX, int velocityY) {
velocityY *= 0.7;
// velocityX *= 0.7; for Horizontal recycler view. comment velocityY line not require for Horizontal Mode.
return super.fling(velocityX, velocityY);
}
}
Adjust speed by Replacing 0.7 to your value.
Now use this class in your XML like this.
<.CustomRecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
Read RecyclerView in Java like.
CustomRecyclerView mRecyclerView;
mRecyclerView = (CustomRecyclerView) findViewById(R.id.my_recycler_view);