Android Honeycomb (Android 3.x) brought with it a new and updated animation system for developers to take advantage of. Shane Conder and Lauren Darcey, authors of Android Wireless Application Development, 2nd Edition, show you how to use the tools to give your application a polished look and a fluid feel.

From the author of

From the author of

Android Honeycomb (Android 3.x) brought with it a new and updated animation system for developers to take advantage of. Instead of visual animating View objects, this new system animates the values of any object. In Android 3.1, the system had a helper class added to simplify animation of View objects. Finally, with the updated animation system comes easier animation for layouts.

Animation and Animator

Android now has two systems of animation. The first, which has existed since Android 1.0, is the Animation package, android.view.animation. The second, and newest, is the Animator set of classes, in the android.animation package. These two packages can be used to accomplish similar animation behaviors, but the new package is far more robust.

The original Animation package is limited to visually animating a View object. In fact, it's only an animation illusion when animating visually drawn location because only where the object is drawn changes. The actual object will still have its original location, which is confusing, because it isn't drawn there.

The new Animator classes are used to change actual property values of any object. Firstly, this means that any property can be animated, or modified over time. Although animation generally refers to a visual change, there's no requirement that the property to be animated be a value that is visible to the user. In fact, there are no requirements about the object at all. Any object with a property can have the property value "animated."

Both packages have access to underlying animation support classes, such as the animation listeners (fired at each "frame" of the animation) and the interpolators (the functions that determine the change in value for each increment of time). In fact, the core interpolators are the same for doing things like "bounce" and "overshoot" effects in both packages.