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—making a ball bounce

Our children's book publisher has come back to us. They thank us kindly for making the ball on the first page roll along correctly, but they are a bit disappointed in page 2. Page 2, if you recall, is a ball that is supposed to bounce.

We'd better fix that now. Let's use a ValueAnimator to change the padding of the ball in the ImageView. Look at the following screenshot to see what we're planning:

Time for action—making a ball bouncevaluesanimating, with ValueAnimator

How the ball-bouncing animation is going to be calculated?

Makes sense? Imagine if, in every frame, we add a little bit to paddingTop and take a little bit away from paddingBottom. The ball will fall down!

We can also ...

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