ondraw

How to extend the View class in Android to create a custom View alvin May 11, 2015 - 11:02am

Android FAQ: How do I write a custom View class in Android? (Or, how do I extend a View class?)

How to draw a circle in Android (onDraw method in View)

Android FAQ: How do I draw a circle in Android?

To draw a circle in Android you just need to create your own View class and then use that in your Activity. For example, the following CustomView shows how to extend a View and draw a circle in the onDraw method:

How to draw a rectangle in Android (using onDraw method of View)

Android FAQ: How do I draw a rectangle in Android?

To draw a rectangle in Android you’ll need to create your own View, i.e., a class that extends the Android View class. For example, this CustomView shows how to extend a View and then use the Rect and Paint classes along with the onDraw method to draw a rectangle: