看代码实现如下:
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
public class PictureDrawView extends View {
private Bitmap cacheBitmap;
public Canvas cacheCanvas;
public Paint paint;
private Paint BitmapPaint;
public Path path;
private int height;
private int width;
public float pX;
public float pY;
private int paintColor = Color.BLACK;
private static Paint.Style paintStyle = Paint.Style.STROKE;
private static int paintWidth = 10;
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
height = h;
width = w;
init();
}
private void init(){
cacheBitmap = Bitmap.createBitmap(width,