Created
December 1, 2015 16:01
-
-
Save elevenetc/57754c3eaaaab6319483 to your computer and use it in GitHub Desktop.
SmoothScroller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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