B4A Library ColorByName - expands dropdown selection

It expands the colors (by name) to choose from when entering for eg Button1.colors = colorbyname.select-a-color. It includes the RGB option. Library files (colorbyname.xml, colorbyname.jar) are in the /files folder of the attached project. A bit less guessing of RGB values. Selection of colors are grouped into:
White (including pastels)
Grays
Blues
Greens
Yellows
Browns
Oranges
Pinks
 

Attachments

  • ColorByName.zip
    13 KB · Views: 439
Last edited:

Derek Johnson

Active Member
Licensed User
Longtime User
Do you have a version of this library for B4I please?

Scratch that - just copied the XML and Jar files and it seems to work in B4I as is.

Sorry - it only seemed to work. When entering code the intellisense feature worked but then it fails to compile saying a parameter is missing. I thought that because it was basically a list of constants I could get away with using the B4A library in B4I, but that is wrong!


Derek
 
Last edited:

Derek Johnson

Active Member
Licensed User
Longtime User
I've now created a code module from the original library that is portable from B4A to B4I and I guess B4J.

Just add the ColorByName.bas file as a code module. If you want to test it in B4A then don't forget to remove the original library from your project.

It behaves in much the same way as the original library with Intellisense.

Derek
 

Attachments

  • ColorByName.bas
    7.6 KB · Views: 327

Johan Schoeman

Expert
Licensed User
Longtime User
This is the original project that I have created the lib from. The B4A code is in the ColorByName code module.

Add the following to the code module to get for eg Material_Red_500:

B4X:
Public Sub Material_Red_500 As Int
Return Colors.RGB(0xf4,0x43,0x36)           'RGB F44336 = Material Red 500
End Sub

Get other Material colors here and just add to the code module....;)
 

Attachments

  • JHS TEST COLOR.zip
    14.3 KB · Views: 302
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
Just as an example... have added Material Red 500, 50, 100, 200, and 300 at the end of the code module. Do the same to add other material colors to the project and then compile it to a lib.
 

Attachments

  • JHS TEST COLOR ADDING MATERIAL COLORS.zip
    14.4 KB · Views: 309

Derek Johnson

Active Member
Licensed User
Longtime User
I've just created this code module with all of the Material Standard Colors eg

B4X:
 Public Const red_50=0XffFFEBEE As Int
    Public Const red_100=0XffFFCDD2 As Int
    Public Const red_200=0XffEF9A9A As Int
    Public Const red_300=0XffE57373 As Int
 .....
    Public Const blue_grey_400=0Xff78909C As Int
    Public Const blue_grey_500=0Xff607D8B As Int
    Public Const blue_grey_600=0Xff546E7A As Int
    Public Const blue_grey_700=0Xff455A64 As Int
    Public Const blue_grey_800=0Xff37474F As Int
    Public Const blue_grey_900=0Xff263238 As Int

Just add the MC.bas as a code module then you can use it like this:

B4X:
Sub Activity_Resume
    Panel1.Color=MC.yellow_A700
End Sub   

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("1")
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Panel1_Click
        Panel1.Color=MC.deep_purple_900
End Sub

Should work in B4A, B4I and B4J

Keywords: Material Design Colors

Derek
 

Attachments

  • MC.bas
    12.2 KB · Views: 372
Top