In the Code, set the TextView font color and textview font color.
There are two common methods:
1. dimens In the res folder. xml, styles. xml or strings. add the <color name = "green"> #00ff00 </color> label to the xml file, or create a color in the res folder. xml file, add the root tag <resource> </resource> to the file, and then add the <color> note in the root tag. Then, you can set the tag in the Code as follows:
TextView. setTextColor (Context. getResources (). getColor (R. color. green ));
2. textView. setTextColor (0xff00ff00 );
Here, "0x" indicates that the value is an integer ff in hexadecimal notation. "ff" indicates that the transparency is not transparent. "00" indicates that the value is completely transparent. "00ff00" indicates that the value is green.
Note: In this method, the value after 0x must be 8 digits, transparency (2 bits) + color value (6 bits)
The text color in textview in android is invalid? Only the first one can display the color. Others are the default ones.
Check whether setEnabled (false) is set in the code)
Android development: how to set the text and background colors of textView statically and dynamically? Beginners do not know what to fill in details
Static is to fill in the attributes in the visualized Graphical Layout.
TextView1.TextColor (text color)
TextView1.Background (background color)
In @ android, all defined color values are automatically displayed.
For example, @ android: color/holo_blue_bright
Dynamic is set color in the program
Import android. graphics. Color;
TextView1.setTextColor (Color. RED );
TextView1.setBackgroundColor (Color. RED );