这是我下面的代码,它在 Circle 内绘制一个 Circle,并将我当前的位置作为圆的中心。我正在我当前的位置显示一个星号标记。
问题陈述:-
下面的代码工作正常,但我遇到的唯一问题是Star Sign Marker
,它不在圆心。我需要我Star Sign Marker
(android.R.drawable.star_on)
总是在圆圈的中心。
imageNames[0]
是以下代码中的圆心(星号标记)。
任何建议都会对我有很大帮助。
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
super.draw(canvas, mapView, shadow);
Point screenPts = new Point();
mapView.getProjection().toPixels(pointToDraw, screenPts);
//--------------draw circle----------------------
Point pt = mapView.getProjection().toPixels(pointToDraw,screenPts);
Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
circlePaint.setColor(0x30000000);
circlePaint.setStyle(Style.FILL_AND_STROKE);
int totalCircle=4;
int radius=40;
int centerimagesize=13;
for (int i = 1; i <= totalCircle; i ++) {
canvas.drawCircle(screenPts.x,screenPts.y, i*radius, circlePaint);
canvas.drawBitmap(BitmapFactory.decodeResource(getResources(),imageNames[i]), ((screenPts.x)+(i*radius)),(screenPts.y), null);
}
canvas.drawBitmap(BitmapFactory.decodeResource(getResources(),imageNames[0]), (screenPts.x-(centerimagesize/2)),(screenPts.y-(centerimagesize/2)), null);
super.draw(canvas,mapView,shadow);
return true;
}
下面是我目前在模拟器中获得的屏幕截图。我需要星号始终位于圆心。我正在运行安卓 4.1