我有一个用于绘制地图图块的ImageView。对于缩放我使用:
matrix.postScale(scale, scale, screenWidth / 2, screenHeight / 2);
imageView.setImageMatrix(matrix);
我将位置标记绘制为30像素半径的圆形,如下所示:
drawGPSMarker(canvas, locX, locY, 30); //canvas: imageView's canvas
是:
public void drawGPSMarker(Canvas canvas, float scrnX, float scrnY, float radius) {
Bitmap bitmap = Bitmap.createBitmap(450, 450, Bitmap.Config.ARGB_8888);
Canvas cnv = new Canvas(bitmap);
Paint paint = new Paint();
....
cnv.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, radius, paint );
paint.setColor(Color.WHITE);
canvas.drawBitmap(bitmap, scrnX - bitmap.getWidth() / 2, scrnY - bitmap.getHeight() / 2, paint);
bitmap.recycle();
}
问题是,当我放大时,imageView会放大,标记位图即使重绘也会变大。任何想法如何限制drawGPSMarker(..)不增长,我的意思是它应该显示相同的大小和厚度,无论imageView的缩放。
有关解释,请参阅附件。
请问?