Last active
August 3, 2019 07:02
-
-
Save momvart/461d39b156e1237a30f5bd042be12b2e to your computer and use it in GitHub Desktop.
A simple android LinearSmoothScroller which scrolls to put the target item to the top of the RecyclerView
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
class StartLinearSmoothScroller(context: Context): LinearSmoothScroller(context) { | |
override fun getVerticalSnapPreference() = SNAP_TO_START | |
} | |
//Example | |
val smoothScroller = StartLinearSmoothScroller(context) | |
smoothScroller.targetPosition = 0 //replace with your target position | |
layoutManager.startSmoothScroll(smoothScroller) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment