Last active
April 28, 2020 11:59
-
-
Save Ash-Kay/4cf04ce54f341ee613904091d80275e4 to your computer and use it in GitHub Desktop.
Spring Animation tutorial
This file contains hidden or 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
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