The two methods are to draw a circle that gradually increases, and the custom view needs to sleep to see the effect. surfaceView is not needed. It may be related to its two-level cache.
_____________________________________ Most beautiful split line _________________________________________
It is mainly used
SurfaceHolder sh = this. getHolder (); ---> 1. Obtain SurfaceHolder.
Canvas canvas = sh. lockCanvas (); ----> 2. Lock the Canvas
Paint paint = new Paint ();
Paint. setColor (Color. RED); -----> 3. Officer on the canvas
Canvas. drawCircle (100,100, radius, paint );
Sh. unlockCanvasAndPost (canvas); -----> 4. Unlock
The following figure shows all the codes.
_____________________________________ Most beautiful split line __________________________________________
View mainly works on the onDraw () method. You do not need to manually call this method (unlike surfaceview, you have to return a surfaceHolder. addCallback () method)
SurfaceHolder in surfaceview. the addCallback () method constantly calls the Draw () method. description of this method document: Manually render this view (and all of its children) to the given Canvas. the view must have already done a full layout before this function is called. when implementing a view, implementonDraw(android.graphics.Canvas)
Instead of overriding this method. If you do need to override this method, call the superclass version.