在我的Android应用程序中,我必须从WebView获取一个图像,然后在其上添加注释。所以,到目前为止,我已经成功实现了这一目标。问题是,一旦绘制了特定的注释,我找不到如何动态缩放它们的解决方案。对于一个直线,一个圆等等。
private void setupDrawing() {
// get drawing area setup for interaction
Log.d("onCreate", "" + "setupDrawing");
drawPath = new Path();
drawRect = new Rect();
drawPaint = new Paint();
drawPaint.setColor(paintColor);
drawPaint.setAntiAlias(true);
drawPaint.setStrokeWidth(5);
drawPaint.setStyle(Paint.Style.STROKE);
drawPaint.setStrokeJoin(Paint.Join.ROUND);
drawPaint.setStrokeCap(Paint.Cap.ROUND);
canvasPaint = new Paint(Paint.DITHER_FLAG);
}
public boolean onTouchEvent(MotionEvent event) {
// detect user touch
Log.d("Event", "onTouchEvent");
if (canDrawFreeHand == true) {
Log.d("", "canDrawFreeHand true");
Log.d("Fag", "Got the Free hand flag " + currentflag);
float touchX = event.getX();
float touchY = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// Log.d("freehand", "draw");
drawPath.moveTo(touchX, touchY);
break;
case MotionEvent.ACTION_MOVE:
// Log.d("freehand", "Drawing..");
drawPath.lineTo(touchX, touchY);
break;
case MotionEvent.ACTION_UP:
Log.d("freehand", "Drawn");
drawCanvas.drawPath(drawPath, drawPaint);
drawPath.reset();
break;
default:
return false;
}
}
我想以这样一种方式缩放它们,即在绘制一些注释之后,当用户点击该绘图时。它已准备好扩展。