Traditional animations can be constructed using a series of images, and Android provides the AnimationDrawable that can accomplish the same. Any number of slightly differing bitmaps can be defined as a list in XML and played in sequence to produce a stop frame animation.
Before we start we will require a number of images to act as the frames of our animation. As few as three or four is enough for demonstration purposes—we used the following:
As always with Android, the PNG format is preferred over other formats, although BMP, JPG and GIF are permitted. Depending on the screen density of your target device, store these bitmaps in the appropriate res/drawable
folder. We called them image01.png
, image02.png
, and so on.