Draw the contents of the view itself, by calling the View.ondraw (canvas) function to implement
Draw your own child through Dispatchdraw (canvas) to achieve
The drawing of the view component invokes the draw (canvas canvas) method, in which the main draw is the drawable background, the drawable call SetBounds (), and then draw (canvas c) method. A bit of note is that the actual size of the background drawable affects the size of the view component, and the actual size of the drawable is obtained through Getintrinsicwidth () and Getintrinsicheight (). The view component size equals the size of the background drawable when the background is relatively large
After drawing the background, the draw process calls the OnDraw (canvas canvas) method, then the Dispatchdraw (Canvas canvas) method, and Dispatchdraw () is mostly distributed to the child components for drawing. We usually rewrite the OnDraw () method when customizing the components. It is noteworthy that the ViewGroup container component is drawn, and when it does not have a background, it calls the Dispatchdraw () method directly, bypassing the draw () method, invoking the draw () method when it has a background, and draw () The method contains a call to the Dispatchdraw () method. So the Dispatchdraw () method instead of the OnDraw () method is often overridden to draw on ViewGroup, or a drawable is customized, and the draw (Canvas C) and Getintrinsicwidth () are rewritten. ,
Getintrinsicheight () method, then set as background.
The difference between OnDraw () and Dispatchdraw ()