AnimationDrawable

The AnimationDrawable is how you define a frame-by-frame animation in Android. It describes a drawable as a list of other drawable resources that are played sequentially to create an animation. This is an animation in the most traditional sense: a sequence of independent images, played one after another.

We can define the frames of an animation in code using the AnimationDrawable class, but it is much easier to use XML. This file lists the frames that compose the animation and their duration. The XML is composed by a root node of the <animation-list> type and a series of child nodes of the <item> type that define a frame using a drawable resource and the frame duration:

<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" ...

Get Android: Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.