Android Code Snippet 140+ Colors Hex/RGB

Add it as a code module. Enjoy! :)

B4X:
#IgnoreWarnings: 9, 12
Private Sub Process_Globals 
    Dim    INDIANRED               = "#CD5C5C"    As String
    Dim    LIGHTCORAL              = "#F08080"    As String
    Dim    SALMON                  = "#FA8072"    As String
    Dim    DARKSALMON              = "#E9967A"    As String
    Dim    LIGHTSALMON             = "#FFA07A"    As String
    Dim    CRIMSON                 = "#DC143C"    As String
    Dim    RED                     = "#FF0000"    As String
    Dim    FIREBRICK               = "#B22222"    As String
    Dim    DARKRED                 = "#8B0000"    As String
    Dim    PINK                    = "#FFC0CB"    As String
    Dim    LIGHTPINK               = "#FFB6C1"    As String
    Dim    HOTPINK                 = "#FF69B4"    As String
    Dim    DEEPPINK                = "#FF1493"    As String
    Dim    MEDIUMVIOLETRED         = "#C71585"    As String
    Dim    PALEVIOLETRED           = "#DB7093"    As String
    Dim    LIGHTSALMON             = "#FFA07A"    As String
    Dim    CORAL                   = "#FF7F50"    As String
    Dim    TOMATO                  = "#FF6347"    As String
    Dim    ORANGERED               = "#FF4500"    As String
    Dim    DARKORANGE              = "#FF8C00"    As String
    Dim    ORANGE                  = "#FFA500"    As String
    Dim    GOLD                    = "#FFD700"    As String
    Dim    YELLOW                  = "#FFFF00"    As String
    Dim    LIGHTYELLOW             = "#FFFFE0"    As String
    Dim    LEMONCHIFFON            = "#FFFACD"    As String
    Dim    LIGHTGOLDENRODYELLOW    = "#FAFAD2"    As String
    Dim    PAPAYAWHIP              = "#FFEFD5"    As String
    Dim    MOCCASIN                = "#FFE4B5"    As String
    Dim    PEACHPUFF               = "#FFDAB9"    As String
    Dim    PALEGOLDENROD           = "#EEE8AA"    As String
    Dim    KHAKI                   = "#F0E68C"    As String
    Dim    DARKKHAKI               = "#BDB76B"    As String
    Dim    LAVENDER                = "#E6E6FA"    As String
    Dim    THISTLE                 = "#D8BFD8"    As String
    Dim    PLUM                    = "#DDA0DD"    As String
    Dim    VIOLET                  = "#EE82EE"    As String
    Dim    ORCHID                  = "#DA70D6"    As String
    Dim    FUCHSIA                 = "#FF00FF"    As String
    Dim    MAGENTA                 = "#FF00FF"    As String
    Dim    MEDIUMORCHID            = "#BA55D3"    As String
    Dim    MEDIUMPURPLE            = "#9370DB"    As String
    Dim    REBECCAPURPLE           = "#663399"    As String
    Dim    BLUEVIOLET              = "#8A2BE2"    As String
    Dim    DARKVIOLET              = "#9400D3"    As String
    Dim    DARKORCHID              = "#9932CC"    As String
    Dim    DARKMAGENTA             = "#8B008B"    As String
    Dim    PURPLE                  = "#800080"    As String
    Dim    INDIGO                  = "#4B0082"    As String
    Dim    SLATEBLUE               = "#6A5ACD"    As String
    Dim    DARKSLATEBLUE           = "#483D8B"    As String
    Dim    MEDIUMSLATEBLUE         = "#7B68EE"    As String
    Dim    GREENYELLOW             = "#ADFF2F"    As String
    Dim    CHARTREUSE              = "#7FFF00"    As String
    Dim    LAWNGREEN               = "#7CFC00"    As String
    Dim    LIME                    = "#00FF00"    As String
    Dim    LIMEGREEN               = "#32CD32"    As String
    Dim    PALEGREEN               = "#98FB98"    As String
    Dim    LIGHTGREEN              = "#90EE90"    As String
    Dim    MEDIUMSPRINGGREEN       = "#00FA9A"    As String
    Dim    SPRINGGREEN             = "#00FF7F"    As String
    Dim    MEDIUMSEAGREEN          = "#3CB371"    As String
    Dim    SEAGREEN                = "#2E8B57"    As String
    Dim    FORESTGREEN             = "#228B22"    As String
    Dim    GREEN                   = "#008000"    As String
    Dim    DARKGREEN               = "#006400"    As String
    Dim    YELLOWGREEN             = "#9ACD32"    As String
    Dim    OLIVEDRAB               = "#6B8E23"    As String
    Dim    OLIVE                   = "#808000"    As String
    Dim    DARKOLIVEGREEN          = "#556B2F"    As String
    Dim    MEDIUMAQUAMARINE        = "#66CDAA"    As String
    Dim    DARKSEAGREEN            = "#8FBC8B"    As String
    Dim    LIGHTSEAGREEN           = "#20B2AA"    As String
    Dim    DARKCYAN                = "#008B8B"    As String
    Dim    TEAL                    = "#008080"    As String
    Dim    AQUA                    = "#00FFFF"    As String
    Dim    CYAN                    = "#00FFFF"    As String
    Dim    LIGHTCYAN               = "#E0FFFF"    As String
    Dim    PALETURQUOISE           = "#AFEEEE"    As String
    Dim    AQUAMARINE              = "#7FFFD4"    As String
    Dim    TURQUOISE               = "#40E0D0"    As String
    Dim    MEDIUMTURQUOISE         = "#48D1CC"    As String
    Dim    DARKTURQUOISE           = "#00CED1"    As String
    Dim    CADETBLUE               = "#5F9EA0"    As String
    Dim    STEELBLUE               = "#4682B4"    As String
    Dim    LIGHTSTEELBLUE          = "#B0C4DE"    As String
    Dim    POWDERBLUE              = "#B0E0E6"    As String
    Dim    LIGHTBLUE               = "#ADD8E6"    As String
    Dim    SKYBLUE                 = "#87CEEB"    As String
    Dim    LIGHTSKYBLUE            = "#87CEFA"    As String
    Dim    DEEPSKYBLUE             = "#00BFFF"    As String
    Dim    DODGERBLUE              = "#1E90FF"    As String
    Dim    CORNFLOWERBLUE          = "#6495ED"    As String
    Dim    MEDIUMSLATEBLUE         = "#7B68EE"    As String
    Dim    ROYALBLUE               = "#4169E1"    As String
    Dim    BLUE                    = "#0000FF"    As String
    Dim    MEDIUMBLUE              = "#0000CD"    As String
    Dim    DARKBLUE                = "#00008B"    As String
    Dim    NAVY                    = "#000080"    As String
    Dim    MIDNIGHTBLUE            = "#191970"    As String
    Dim    CORNSILK                = "#FFF8DC"    As String
    Dim    BLANCHEDALMOND          = "#FFEBCD"    As String
    Dim    BISQUE                  = "#FFE4C4"    As String
    Dim    NAVAJOWHITE             = "#FFDEAD"    As String
    Dim    WHEAT                   = "#F5DEB3"    As String
    Dim    BURLYWOOD               = "#DEB887"    As String
    Dim    TAN_COLOR               = "#D2B48C"    As String
    Dim    ROSYBROWN               = "#BC8F8F"    As String
    Dim    SANDYBROWN              = "#F4A460"    As String
    Dim    GOLDENROD               = "#DAA520"    As String
    Dim    DARKGOLDENROD           = "#B8860B"    As String
    Dim    PERU                    = "#CD853F"    As String
    Dim    CHOCOLATE               = "#D2691E"    As String
    Dim    SADDLEBROWN             = "#8B4513"    As String
    Dim    SIENNA                  = "#A0522D"    As String
    Dim    BROWN                   = "#A52A2A"    As String
    Dim    MAROON                  = "#800000"    As String
    Dim    WHITE                   = "#FFFFFF"    As String
    Dim    SNOW                    = "#FFFAFA"    As String
    Dim    HONEYDEW                = "#F0FFF0"    As String
    Dim    MINTCREAM               = "#F5FFFA"    As String
    Dim    AZURE                   = "#F0FFFF"    As String
    Dim    ALICEBLUE               = "#F0F8FF"    As String
    Dim    GHOSTWHITE              = "#F8F8FF"    As String
    Dim    WHITESMOKE              = "#F5F5F5"    As String
    Dim    SEASHELL                = "#FFF5EE"    As String
    Dim    BEIGE                   = "#F5F5DC"    As String
    Dim    OLDLACE                 = "#FDF5E6"    As String
    Dim    FLORALWHITE             = "#FFFAF0"    As String
    Dim    IVORY                   = "#FFFFF0"    As String
    Dim    ANTIQUEWHITE            = "#FAEBD7"    As String
    Dim    LINEN                   = "#FAF0E6"    As String
    Dim    LAVENDERBLUSH           = "#FFF0F5"    As String
    Dim    MISTYROSE               = "#FFE4E1"    As String
    Dim    GAINSBORO               = "#DCDCDC"    As String
    Dim    LIGHTGRAY               = "#D3D3D3"    As String
    Dim    SILVER                  = "#C0C0C0"    As String
    Dim    DARKGRAY                = "#A9A9A9"    As String
    Dim    GRAY                    = "#808080"    As String
    Dim    DIMGRAY                 = "#696969"    As String
    Dim    LIGHTSLATEGRAY          = "#778899"    As String
    Dim    SLATEGRAY               = "#708090"    As String
    Dim    DARKSLATEGRAY           = "#2F4F4F"    As String
    Dim    BLACK                   = "#000000"    As String
End Sub

Sub RGB(colorName As String) As Int()
    Dim R = Bit.ParseInt(colorName.SubString2(1, 3), 16) As Int
    Dim G = Bit.ParseInt(colorName.SubString2(3, 5), 16) As Int
    Dim B = Bit.ParseInt(colorName.SubString2(5, 7), 16) As Int
    Return Array As Int(R, G, B)
End Sub

Usage:
B4X:
Dim RGB() = myColors.RGB(myColors.RED) As Int
Log("Hex: " & myColors.RED)
Log("RGB: " & RGB(0), & ", " & RGB(1) & ", " & RGB(2))

'Output:
'    #FF0000
'    255, 0, 0
 
Last edited:

JohnC

Expert
Licensed User
This is a big help! It's very frustrating trying to set colors in code to the same value as in the designer, but the "COLORS.xxx" keyword only supports like 16 colors and not all the ones in the designer.

Thank you for taking the time to hand-code all this and sharing it :)
 

Rusty

Well-Known Member
Licensed User
The line:
B4X:
Log("RGB: " & RGB(0), & ", " & RGB(1) & ", " & RGB(2))
should be:
B4X:
Log("RGB: " & RGB(0) & ", " & RGB(1) & ", " & RGB(2))

The extra comma after RGB(0) was there errantly.
 

Similar Threads

Top