Android Tutorial Finding random RGB colors

In building apps, content and appearance are both important, as it is in the design of most everything.

Unique colors make your apps pop and look different from the run of the mill stuff out there. RGB (red, green, blue) color combinations give us over 16 MILLION choices.

Last year, while writing my book GOOGLE APP INVENTOR, one of the first apps I made was a random color generator (it's in the book). This was so durn handy and a great spur to creativity that it's one of the first things I'm doing while coming up to speed in B4A.

The concept and code (attached, enjoy) are pretty basic (pun, as always, intended). Using the app, find a color you like (the Reset button generates 10 new ones at a time, or tap on any bar and that bar changes color). Once found, you can use those three numbers like this:

In the Properties of a view, change Drawable to GradientDrawable. Click in First Color and in the drop down selector (at bottom) type in your RGB numbers. (see below).

enterRGB.png


Now some of you may say, "Hey, Erel's already got a nice gradient selector in there that lets you do the same thing."

Yep, but I've found seeing different colors and how they interact with each other starts the old creative juices flowing.

Besides, it's a learning process. Hope it helps you guys as well.

--Ralph
 

Attachments

  • rcol2.png
    rcol2.png
    38 KB · Views: 695
  • rcol3.png
    rcol3.png
    76.5 KB · Views: 556
  • rndColors.zip
    86.7 KB · Views: 733
Last edited:

author

Member
Licensed User
Longtime User
Thank you for sharing this.

and thank YOU, Erel, for creating this wonderful system that makes it all possible. I am very much enjoying learning how and creating apps in B4A.

--ralph
 

Askjerry

Member
Licensed User
Longtime User
Designer to Code

What I need is a DESIGNER to CODE conversion.

For example... I like the color "GOLD" in the designer...

If you do something like button1.Color="GOLD" you are going to get a fail.
(Obviously)

If you look at the designer... it gives you "255,215,0" so you might think that it's supposed to be button1.Color=255,215,0 but again you would be wrong.

I really wish the designer would output the number in a directly usable form... like a hex or decimal number. Looking here...
HTML Color Names

I can see that "GOLD" is #FFD700 (HEX)... at least for HTML.
Going here... #ffd700 hex color

Marginally helpful...

And as soon as I ask... I find the answer myself...

button1.Color=Colors.RGB(255,215,0) (With the numbers from the designer.)

Thanks,
Jerry
 
Last edited:

roarnold

Active Member
Licensed User
Longtime User
it should upon adding the period after Colors offer you a list of colors. In any case attached is a list of colors in an .xl spreadsheet that might help.

R
 

Attachments

  • Color Chart.zip
    17.7 KB · Views: 523
Top