By Barry Burd

You may decide that you need some fancy animation in your Android app. That shows some promising ambition! Android has two types of animation that you can use in the development of your app:

  • View animation: An older system in which you animate with either tweening or frame-by-frame animation, as described in this list:

    • Tweening: You tell Android how an object should look initially and how the object should look eventually. You also tell Android how to change from the initial appearance to the eventual appearance. (Is the change gradual or sudden? If the object moves, does it move in a straight line or in a curve of some sort? Will it bounce a bit when it reaches the end of its path?)

      With tweening, Android considers all your requirements and figures out exactly how the object looks between the start and the finish of the object’s animation.

    • Frame-by-frame animation: You provide several snapshots of the object along its path. Android displays these snapshots in rapid succession, one after another, giving the appearance of movement or of another change in the object’s appearance.

      Movie cartoons are the classic example of frame-by-frame animation, even though, in modern moviemaking, graphics specialists use tweening to create sequences of frames.

  • Property animation: A newer system (introduced in Android 3.0, API Level 11) in which you can modify any property of an object over a period of time.

    With property animation, you can change anything about any kind of object, whether the object appears on the device’s screen or not. For example, you can increase an earth object’s average temperature from 15° Celsius to 18° Celsius over a period of ten minutes. Rather than display the earth object, you can watch the way average temperature affects water levels and plant life, for example.

    Unlike view animation, the use of property animation changes the value stored in an object’s field. For example, you can use property animation to change a widget from being invisible to being visible. When the property animation finishes, the widget remains visible.

Here are a few specialized animation classes:

  • AlphaAnimation: Fades into view or fades out of view.

  • RotateAnimation: Turns around.

  • ScaleAnimation: Changes size.

  • TranslateAnimation: Moves from one place to another.