belongs to Maven artifact com.android.support:support-dynamic-animation:28.0.0-alpha1
SpringAnimation
public
final
class
SpringAnimation
extends DynamicAnimation<SpringAnimation>
java.lang.Object | ||
↳ | android.support.animation.DynamicAnimation<android.support.animation.SpringAnimation> | |
↳ | android.support.animation.SpringAnimation |
SpringAnimation is an animation that is driven by a SpringForce
. The spring force defines
the spring's stiffness, damping ratio, as well as the rest position. Once the SpringAnimation is
started, on each frame the spring force will update the animation's value and velocity.
The animation will continue to run until the spring force reaches equilibrium. If the spring used
in the animation is undamped, the animation will never reach equilibrium. Instead, it will
oscillate forever.
Developer Guides
To create a simple SpringAnimation
that uses the default SpringForce
:
// Create an animation to animate view's X property, set the rest position of the // default spring to 0, and start the animation with a starting velocity of 5000 (pixel/s). final SpringAnimation anim = new SpringAnimation(view, DynamicAnimation.X, 0) .setStartVelocity(5000); anim.start();
Alternatively, a SpringAnimation
can take a pre-configured SpringForce
, and
use that to drive the animation.
// Create a low stiffness, low bounce spring at position 0. SpringForce spring = new SpringForce(0) .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY) .setStiffness(SpringForce.STIFFNESS_LOW); // Create an animation to animate view's scaleY property, and start the animation using // the spring above and a starting value of 0.5. Additionally, constrain the range of value for // the animation to be non-negative, effectively preventing any spring overshoot. final SpringAnimation anim = new SpringAnimation(view, DynamicAnimation.SCALE_Y) .setMinValue(0).setSpring(spring).setStartValue(1); anim.start();
Summary
Inherited constants |
---|
![]()
android.support.animation.DynamicAnimation
|
Inherited fields |
---|
![]()
android.support.animation.DynamicAnimation
|