Use of dispatchDraw(Canvas canvas)
From the Android documentation - protected void dispatchDraw (Canvas canvas)
:
Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).
For example, ViewGroup
is the Parent of Linear-, Relative-, FrameLayout-, AbsoluteLayout. 1
Because the ViewGroup Class is abstract, directly creating an Instance is not possible.
You can use 1 from this, with the function:
dispatchDraw(Canvas canvas)
For unknown reasons, classes 1 wouldn't draw with
onDraw(Canvas canvas)
Drawing with
dispatchDraw(Canvas canvas)
is in this Classes 1, possible and it is fun to create UI's.
It would look like this:
/////
public class MainActi extends MyLinearLayout. public MainActi(Context con...super(cont...)MyLinearLayout extends LinearLayout @Override protected void dispatchDraw(Canvas canvas) {canvas.drawColor(Color.YELLOW);
...///
Or you skip-back to draw with
onDraw(Canvas canvas)
extending in the MainActivity
"View" or refer it in a extern class like this:
MyMelIsDrawing extends View onDraw(Canvas canvas) //now draw...