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

  • SEARCH
  • Home
  • 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 7977497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:12:59+00:00 2026-06-04T09:12:59+00:00

I have a application where i want to generate dots like 2 x 2,

  • 0

I have a application where i want to generate dots like 2 x 2, 3 x 3 and 4 x 4 dynamically
like this

now i am drawing dot matrix without dynamic using code as follows :

if(test.equals("galmenu2"))
            {
            canvas.drawCircle(wid/4,3*ht/8,3, mPaint);
            canvas.drawCircle(3*wid/4,3*ht/8,3, mPaint);
            canvas.drawCircle(3*wid/4,5*ht/8,3, mPaint);
            canvas.drawCircle(wid/4,5*ht/8,3, mPaint);
            }
            else if(test.equals("galmenu3"))
            {
                canvas.drawCircle(wid/4,3*ht/8,3, mPaint);
                canvas.drawCircle(wid/2,3*ht/8,3, mPaint);
                canvas.drawCircle(3*wid/4,3*ht/8,3, mPaint);
                canvas.drawCircle(wid/4,ht/2,3, mPaint);
                canvas.drawCircle(wid/2,ht/2,3, mPaint);
                canvas.drawCircle(3*wid/4,ht/2,3, mPaint);

                canvas.drawCircle(wid/4,5*ht/8,3, mPaint);
                canvas.drawCircle(wid/2,5*ht/8,3, mPaint);
                canvas.drawCircle(3*wid/4,5*ht/8,3, mPaint);

            }
            else if(test.equals("galmenu4"))
            {
                for(wid=1/8;wid<1;wid+=2/8)
                {
                for(ht=5/16;ht<3/4;ht+=1/8)
                {
                    canvas.drawCircle(wid,ht,3, mPaint);
                }
                }//this for loop crash the application 
            }

and i need a formula to generate dots in my center of canvas please help me
The code mentioned above is added in onDraw() method Thanks in advance

  • 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-04T09:13:00+00:00Added an answer on June 4, 2026 at 9:13 am

    To draw n by n circles on the canvas, I’d use the following:

    // n is defined
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
             canvas.drawCircle(((float)i +.5)/n*(float)width, ((float)j +.5)/n*(float)width, 3, mPaint);
         }
    }
    

    What is happening here?
    We loop through n*n drawing commands:

    • Draw at (i+.5)/n, which is a number between 0 and 1, which is the percentage of the width of the canaws where our coordinate is.
    • Multiply it by the width to get the actual pixel coordinate
    • Do the same with the height.
    • Notice the (float) casts, which are needed to make sure the percentage is not rounded as an int.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application that we want to make available to the general internet-using
I Have application is implemented in JSP, HTML, JS, CSS and now i want
I have this application developed for Blackberry 4.5. I´m using Eclipse, and I want
I have Windows application in csproj in my solution, and I want generate Publish
i have an application for which i want use some reporting framework to generate
I have an application and I want to move some of the tables from
I have an application where I want to simulate the connection between a device
I have this application that I want to support multi languages. I thought the
i have application who use specific process during running and i want to sample
I have an application and executables. I want my application to run my executables.

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.