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

Drawing a surface on the screen

A surface is essentially a rectangle of screen space, such as a blank sheet of paper without any view management code or anything like that. You can write graphics to a surface via a Canvas object; there are other tools to address a surface, but the Canvas is the most interesting one for us right now because it gives us some good tools for drawing our animation.

We now know a little bit about surfaces, but how do we intend to draw one on the screen? There is a convenient view subclass called SurfaceView that takes care of the boundary between our raw surface area and any Android views that may be on the screen. In the next example, we will use a SurfaceView to draw some bubbles, and a game loop to animate it.

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