1.自定义一个imageview用来设定surfaceview上的特定区域。
public class DrawImageView extends ImageView {
private Paint paint;
private int mFristPointX = 100, mFristPointY = 200;
private int mSecondPointX = 400, mSecondPointY = 500;
private boolean isFirstDown = true;
private int mOldX = 0, mOldY = 0;
public DrawImageView(Context context) {
super(context);
// TODO Auto-generated constructor stub
init();
}
public DrawImageView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
init();
}
private void init() {
paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.RED);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(2.5f);
paint.setAlpha(100);
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
canvas.drawRect(new Rect(getmFristPointX(), getmFristPointY(), getmSecondPointX(), getmSecondPointY()), paint);
}
@Override
public boolea