Skip to content

Instantly share code, notes, and snippets.

@elevenetc
Created December 1, 2015 16:01
Show Gist options
  • Save elevenetc/57754c3eaaaab6319483 to your computer and use it in GitHub Desktop.
Save elevenetc/57754c3eaaaab6319483 to your computer and use it in GitHub Desktop.
SmoothScroller.java
//https://mcochin.wordpress.com/2015/05/13/android-customizing-smoothscroller-for-the-recyclerview/
//smoothScrollToPosition(0);
private class SmoothScroller extends LinearSmoothScroller {
private static final float MILLISECONDS_PER_INCH = 400f;
public SmoothScroller(Context context) {
super(context);
}
@Override public PointF computeScrollVectorForPosition(int targetPosition) {
return SmoothLinearLayoutManager.this.computeScrollVectorForPosition(targetPosition);
}
@Override protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return MILLISECONDS_PER_INCH / displayMetrics.densityDpi;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment