We usually extract the colors displayed on the interface to RES/values/color, which facilitates the acquisition and management.
How can we get the color value in the color file and set the background color for iview.
First:
If you write this in color, <color name = "Item1"> # eed776 </color>
In this case, you should obtain the background color of the view.
View. setbackgroundcolor (context. getresources (). getcolor (R. color. Item1 ));
Because: View sets the background color, only eight color values are recognized.
Second
If you write this in the file, <color name = "Item1"> # ffeed776 </color>
FF indicates transparency
You can directly use
View. setbackgroundcolor (R. color. Item1 );
Third
You can directly use
<Span style = "font-family: simsun; font-size: 18px;"> <textview Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: background = "@ color/item0" Android: text = "color"/> </span>
Gets the color value in RES/values/color and sets the background for the view.