Book Image

Mastering Android Game Development

By : Raul Portales
Book Image

Mastering Android Game Development

By: Raul Portales

Overview of this book

Table of Contents (18 chapters)
Mastering Android Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
API Levels for Android Versions
Index

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"
  android:oneshot=["true" | "false"] >
  <item
    android:drawable="@[package:]drawable/drawable_resource_name"
    android:duration="integer" />
</animation-list...