分两个类实现:分别是 Draw 类 和 MainActivity 类
Draw类:
package com.example.painter;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;
import android.view.View;
public class Draw extends View implements View.OnClickListener
{
private float start_x;//声明起点坐标x
private float start_y;//声明起点坐标y
private float end_x;//声明终点坐标x
private float end_y;//声明终点坐标y
private Canvas canvas;//声明画笔
private Paint paint;//声明画布
private Bitmap bitmap;//声明位图
public Draw(Context context)
{
super(context);
// TODO 自动生成的构造函数存根
paint = new Paint(Paint.DITHER_FLAG);//创建一个画笔
bitmap = Bi