This is a quote, because I find that many places contain this part of the content, extract this part of the content, directly quote this part of the content where necessary, at the same time, content like this will also increase according to my knowledge.

1. Use RGB mode

RGB mode, the so-called RGB, is the abbreviation of the three colors red green blue, also referred to as the three primary colors, expressed in hexadecimal, that is, the value range is 0-F, one of the items if 0, it means that there is no such color; If it’s f, then it’s 100 percent of this color; Such as:

  • #f00On behalf of the red
  • #0f0On behalf of the green
  • #00fOn behalf of the blue
  • #f00On behalf of the yellow

This is the color light plus color method category, which is why #000 is black, because there is no light, of course it is black. Generally this way is only for their own testing time will use, in the work will rarely be directly spelled like this, unless there is no design.

2. Use RRGGBB mode

So this is the same meaning as above, which is the range from 00 to ff, which means more colors; Here are some common colors:

  • #ff0000red
  • #00ff00green
  • #0000ffblue

Here is a website that can get its own hexadecimal color values: HTMLColorCodes.

3. Use AARRGGBB mode

This differs from the above by adding AA, where AA is transparency and values range from 00 to ff, but normally the UI gives a design diagram as a percentage, like this:

We find that even if we switch the corresponding hexadecimal, it shows yesFFIn fact, we know that it is not 100%. The correct way is to do something like this:

The percentage of transparency is to the right of the color you chooseAHEXPattern discovery is normal. But if you set the color value to supportrrggbbaaMode, then both are OK.

4. Use the RRGGBBAA decimal mode

The usual values are rgba(RR, GG, BB, AA) in decimal notation, ranging from 0 to 256; The value of AA ranges from 0.0 to 1.0 floating point. Such as:

  • rgba(255, 0, 0, 0)red
  • Rgba (0, 255, 0, 0.5)It’s half transparent green

In 5.colors.xml, and then introduced

In Android development, it is common to put colors in the corresponding colors.xml file and introduce them where necessary. First find the colors.xml file in the project, under the module > res > values, and define the format as follows:


      
<resources>
    <color name="orangeRed">#f45321</color>
</resources>
Copy the code

The color values follow 1,2,3 above. Android :textColor=”@color/orangeRed”; android:textColor=”@color/orangeRed”; R.color.orangered can be used in code.