两种方法都是实现画一个慢慢变大的圆, 自定义的view要sleep一下才能看到效果 . surfaceView不用. 可能与其两级缓存有关.
_____________________________________最美分割线_________________________________________
使用它主要就是
SurfaceHolder sh = this.getHolder();--->1.得到SurfaceHolder
Canvas canvas = sh.lockCanvas();---->2. 锁定画布
Paint paint = new Paint();
paint.setColor(Color.RED); ----->3. 在画布上干事
canvas.drawCircle(100, 100, radius, paint);
sh.unlockCanvasAndPost(canvas); ----->4. 解除锁定
下面图片为全部代码.
_____________________________________最美分割线__________________________________________
view主要干活的是onDraw()方法.这个不用手动调(不像surfaceview还得还一个surfaceHolder.addCallback()方法)
其实surfaceview里的surfaceHolder.addCallback()方法是不断的调用Draw()方法. 这个方法文档的解释: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.