I have succesfully extended a view and overridden the onDraw() method
I can draw simple graphics in the view’s onDraw() method, but I want more 🙂
I would like to draw an object containing it’s own rectangles, lines and text. Is it possible to create an object with it’s on onDraw() and then call my object’s draw() methos inside my view?
If possible i would like to do somethin like this:
class MySmileys extends View{
Smiley smiley = new Smiley();
...
onDraw(...){
smiley.draw();
}
}
Thanks in advance, looking forward to hear from you.
Yes, it is possible. Drawables in Android work this way (exactly as your example even).
Just make sure to pass the correct canvas to the
draw()method.