Skip to content

Instantly share code, notes, and snippets.

@AshuTyagi16
Last active June 24, 2020 06:22
Show Gist options
  • Save AshuTyagi16/9e6e8d3b6877c12ddfff5e58b7ff21db to your computer and use it in GitHub Desktop.
Save AshuTyagi16/9e6e8d3b6877c12ddfff5e58b7ff21db to your computer and use it in GitHub Desktop.
rvApps.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
recyclerView.forEachVisibleHolder { holder: AppViewHolder ->
holder.rotation
// Update the velocity.
// The velocity is calculated by the vertical scroll offset.
.setStartVelocity(holder.currentVelocity - dx * SCROLL_ROTATION_MAGNITUDE)
// Start the animation. This does nothing if the animation is already running.
.start()
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment