Android Canvas demo app

Let's make an app that uses the Canvas and Paint classes and do a bit of drawing. This example will be completely static (no animation), so we can clearly see how to use Canvas and Paint without cluttering up the code with things we will learn later.

In this demo app, we use some conceptually helpful variable names to help us grasp the role that each object is playing. But we will go through the whole thing at the end to make sure we know exactly what is going on at each stage. Of course, you don't have to type all this in; you can open the completed code files from the Canvas Demo folder in the Chapter 28 folder of the download bundle.

Start a new project and call it Canvas Demo. Open the layout_main.xml file, and edit it ...

Get Android Programming for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.