Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define a custom color variable

Tags:

I want to change some button colors globally in my code. I cannot seem to fine a way to define a color variable and then assign a color value to that variable.

I tried this Color SelectedColor = new Color();

      f1.setBackgroundColor(Color.rgb(0, 0, 100)); 

I want to use ColorSelected in place of the RGB value so I can edit the value at start up.

          f1.setBackgroundColor(Color.ColorSelected); 
like image 548
Bobby Avatar asked Jul 19 '13 15:07

Bobby


People also ask

What is a variable color?

With Color Variables, you can set colors that synchronize across your document. When you make changes to a Color Variable, those changes appear across all of the layers that use it. You can create Color Variables that are local to a specific document or share them in a Library to use in other designs.

How can we use custom colors in application?

Click New —> Values resource file menu item to popup the New Resource File dialog window. In the New Resource File dialog window, input keyword colors in the File name input box, select main in the Source set drop-down list, input values in the Directory name input text box, then click the OK button. Then colors.

How do I add color to XML?

then you need to look in android. jar >> android >> R. class >> R >> color . This should be higher up on the list.


1 Answers

you can use values/colors.xml. For instance

<?xml version="1.0" encoding="utf-8"?> <resources>     <color name="menu_background">#666666</color> </resources> 
like image 169
Blackbelt Avatar answered Oct 09 '22 07:10

Blackbelt