Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8404787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:41:19+00:00 2026-06-09T22:41:19+00:00

This is my below code which is drawing a Circle within Circle and taking

  • 0

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

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:41:21+00:00Added an answer on June 9, 2026 at 10:41 pm

    To me it seems like you forgot to take your markers size in account. You should probably start to draw somewhere like:

    screenPts.x - (centerimagesize + starSignWidth)/2
    screenPts.y - (centerimagesize + starSignHeight)/2
    

    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:

    Draw the specified bitmap, with its top/left corner at (x,y)

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code like this below, which gives me a $link that equals
So I'm drawing this triangle in android maps using the code below in my
I have this below code and it work fine header (content-type: text/xml); $xml =
This code below allows me to find the word error in all my files
This code below is for executing ls -l | wc -l. In the code,
This code below works in all web browsers except IE: <input type="text" name="passwordLogin" value="Password"
This code below doesn't work correctly since my MFC program is in unicode circumstance.
This is my below code, I am confuse why this thing is happening. In
This is my below code and I want to catch the exception if any
I have this code below. I need to use a class id instead of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.