small medium large xlarge

Back to: All Forums  Hello, Android
07 Oct 2009, 23:08
Win Myo Htet (31 posts)

There are two methods in View for drawing. One is onDraw(Canvas canvas) and the other is draw(Canvas canvas). onDraw() is being called by the system and draw() is for manual drawing. How can I use draw(Canvas canvas)? How can I get canvas? Do I create Canvas canvas=new Canvas()?

08 Oct 2009, 22:21
Ed Burnette (1341 posts)

You should not call or implement the draw() function. If you look at the source code (;a=blob_plain;f=core/java/android/view/;hb=refs/heads/donut-release) you’ll see that the draw() method does a few things like drawing the background and handling fade, then calls your onDraw() function. All your real drawing calls should be in your onDraw() function.