Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com

Here we use two classes, one of which extends View.

When the activity is created, an instance of CanvasView is made and set as content.

A reference to the activity, this,...

is passed to the CanvasView constructor, that passes it on to the View constructor.

The onDraw method is called first....

with just these values as coordinates.

When touching...

and moving on the app,...

the coordinates change accordingly...

and the onDraw method is called due to the invalidate call.

A Paint instance is needed for colour and other settings,...

passed in to draw method calls as p.

About the colours :

opaque, full red

somewhat transparent,99, and full green combined with full blue, making cyan.

somewhat transparent and full green.

Red lines drawn first, creating the depth illusion.

Then a transparent cyan rectangle...

and on top of that a transparent green circle.

Of course Canvas has more drawing methods, like drawText, but this is a start.

.