Esempio n. 1
0
 void myDraw() {
   float width, height;
   width = getMeasuredWidth();
   height = getMeasuredHeight();
   canvas = holder.lockCanvas();
   canvas.drawColor(Color.GREEN);
   canvas.drawPath(path, paint);
   holder.unlockCanvasAndPost(canvas);
 }
Esempio n. 2
0
  public void mDraw() {

    mCanvas = mHolder.lockCanvas(); // 获得画布对象,开始对画布画画

    mCanvas.drawColor(++i); // 设置画布颜色为黑色

    canvasMethod(mCanvas); // 调用自定义的方法,主要是在传进去的画布对象上画画

    mHolder.unlockCanvasAndPost(mCanvas); // 把画布显示在屏幕上
  }