O'Reilly logo

Android 3.0 Animations by Alex Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. 2D Graphics with Surfaces

We've seen that Android provides a wealth of features for creating animations by interchanging and manipulating images. But what if we want direct control of the code that performs the animation?

By combining an Android display element called a surface, with a technique from computer game programming called a game loop, we can programmatically create animations in an efficient way. This is useful for creating fast animated widgets with a unique style.

In this chapter, we shall do the following:

  • Create a surface and make it usable
  • Write a game loop
  • Learn about some drawing tools that are useful for animation
  • Optimize our animation for smoothness

So let's get on with it.

Introducing game loops

Game loops are single-threaded ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required