Skip to content

Instantly share code, notes, and snippets.

@Ash-Kay
Last active April 28, 2020 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ash-Kay/4cf04ce54f341ee613904091d80275e4 to your computer and use it in GitHub Desktop.
Save Ash-Kay/4cf04ce54f341ee613904091d80275e4 to your computer and use it in GitHub Desktop.
Spring Animation tutorial
val stiffness = 5f
val animCircleX: SpringAnimation = SpringAnimation(circle_btn,DynamicAnimation.TRANSLATION_X)
.apply {
spring = SpringForce().setDampingRatio(SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY)
.setStiffness(stiffness)
}
animCircleX.cancel() // cancel old animation to play new animation
animCircleX.spring.finalPosition = touchPoint.x - Constants.circleSize //set final postion as touchPosition
animCircleX.start() //start new animation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment