O'Reilly logo

Android 3.0 Animations by Alex Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—improving our bouncing ball

The bouncing ball looks a little unnatural bouncing like that. Let's specify another interpolator that will make the bouncing action look a little bit more natural.

  1. Open up InteractiveBook.java. Add another import at the top of the file.
    import android.view.animation.BounceInterpolator;
    

    You might remember that we used one of these in the previous chapter. We want a bouncing action, so we should use a bouncing action, right? I'm not sure, let's try it and see if it works.

  2. Next, go to the onCreate() method, and find the part where you were specifying parameters for the ballBouncer. Add the highlighted line in the following block of code:
    ballBouncer.setDuration(2000); ballBouncer.setRepeatMode(ValueAnimator.REVERSE); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required