This is my below code which is drawing a Circle within Circle and taking my current location as the center of the circle. And I am showing a Star Sign Marker on my current location.
Problem Statement:-
Below code is working fine, but the only problem I am having is, the Star Sign Marker, it is not coming in the center of circle. I need my Star Sign Marker (android.R.drawable.star_on) always in the center of the circle exactly.
imageNames[0] is the Center of the Circle (Star Sign Marker) in the below code.
Any suggestions will be of great help to me.
@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;
}
Below is the screenshot which I am getting currently in my emulator. I need star sign always to be in the center of circle. I am running android 4.1

To me it seems like you forgot to take your markers size in account. You should probably start to draw somewhere like:
All you actually do is to tell the canvas to start drawing your markers top left corner in the middle of the screen. Which means that the star markers center won’t be the same as your screens center.
The API for Canvas.drawBitmap(Bitmap bitmap, float left, float top, Paint paint) says:
http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap%28android.graphics.Bitmap,%20float,%20float,%20android.graphics.Paint%29
Which is exactly what you do. Your markers top left corner is in the middle of the screen.