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 7816747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:58:52+00:00 2026-06-02T05:58:52+00:00

I am still new at android development and all the app i’ve been dealing

  • 0

I am still new at android development and all the app i’ve been dealing with so far are not graphical related. Now i am making a app that displays a graph, pie graph to be exact and im making this without any 3rd party libs. This is the tutorial which i followed.

Now the problem is the data which i will be using to construct the graph is dynamic, and so to assign each item with a color for the graph i need to generate a number of random colors for the canvas.drawColor. the number of colors will of course depend on my dynamic data which is determined at run time and the color value also needs to be generated.
Also it would be nice if the colors generated are vibrant colors that stands out.

I’ve never dealt with canvas, any idea how this can be done? Example code would be much appreciated.

Thanks

  • 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-02T05:58:53+00:00Added an answer on June 2, 2026 at 5:58 am

    It would be quite hard to get different and usefull colors at runtime. The best is not to use so much randomness, but make an array of let’s say 20 fixed colors quite distinct and use the X first ones for your data. If you need more, then maybe use real random colors using random RGB values :

    Random r = new Random();
    Color c = new Color( r.nextInt(255), r.nextInt(255), r.nextInt(255) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am still pretty new to Android development, and I have not been able
I'm a new comer in Android development and still on my first app. While
I have been learning android development and I am still new to this. I
I'm still relatively new to Java and Android development, so I'm still unfamiliar with
I'm new to android game development. I currently working on a simple android app
I am new to Android and Eclipse development, but not new to software development
I'm new to Android development and it's been a long time since I've done
I've just started Android development with Eclipse, so I've been going through all the
I'm still new to programming/Java/Android so I'm trying to understand everything I do and
I'm pretty new to Android dev and still working out a lot of things.

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.