Animation by Canvas

Animation in Android
Sometimes animating only View's subclasses is not sufficient. If we want to draw all the stuff, it may be a good idea to use Canvas, inside onDraw() method of the view. It allows drawing anything from simple circle to bezier curves or text.

Example 1: Create a new project with an empty template. To create a new custom view extend the view class as shown below. It is very important to have an exact look at the View's life cycle described in custom view in android.


Then edit the activity_main.xml.


The MainActivity.java is shown below.


You can see the result here.


Comments