A simple spring animation (support library v25.3.0+) example android app

Min SDK   16
Latest Commit   2017-06-15 13:42:28
License   unknown

Github   https://github.com/graviton57/DynamicAnimationExample






Chernivtsi, Ukraine


SignUpTransition A cool material sign up transition.
Primer Intro Animation like Google Primer
AppIntroAnimation AppIntroAnimation is a set of code snippets to make cool intro screen for your app with special Image Translation and Transformation animation effects. It is very easy to use and customize without adding third party library integrations.


Dynamic Animation Example

Android Arsenal License API

Dynamic-animation is a new module introduced in revision 25.3.0 of the Android Support Library. It provides a small set of classes for making realistic physics-based view animations.


To get started, add the following dependency to your module’s build.gradle:

dependencies {
    compile 'com.android.support:support-dynamic-animation:25.3.0'

support-dynamic-animation:25.3.0 new physics-based animation library that provides a set of APIs for building animations that dynamically react to user input

Making a SpringAnimation

Well, it won’t really be generic in a programming sense, but let’s start with how every SpringAnimation is made.

  1. Create a SpringAnimation object for your View with a specified ViewProperty
  2. Create a SpringForce object and set your desired parameters (which are described above).
  3. Apply the created SpringForce to your SpringAnimation.
  4. Start the animation.
 private void startSpringAnimation(View view){
        // create an animation for your view and set the property you want to animate
        SpringAnimation animation = new SpringAnimation(view, SpringAnimation.X);
        // create a spring with desired parameters
        SpringForce spring = new SpringForce();
        // can also be passed directly in the constructor
        // optional, default is STIFFNESS_MEDIUM
        // optional, default is DAMPING_RATIO_MEDIUM_BOUNCY
        // set your animation's spring
        // animate!


alt text


Let’s say we have an arbitrary view positioned in the center of the screen We want to achieve the following behavior:

  1. Drag the view.
  2. Move it around.
  3. Release it.
  4. The view springs back to its original position.


There’s a rotating view on our screen which behaves like this:

  1. Grab the view.
  2. Spin it.
  3. Release it.
  4. The view spins back to its original position, again with a bounce.


As usual, there’s a view on our screen (it could be a photo) which has the following behavior:

  1. Grab it with 2 fingers.
  2. Do a typical pinching gesture to zoom in or out.
  3. Release it.
  4. The view scales back to its original size.

Feel free to fork, contribute and poke at the code.

Developed By

Igor Havrylyuk (Graviton57)