http://blog.csdn.net/fth826595345/article/details/9208771 ThemesTextView
Reprint Please specify source: http://blog.csdn.net/fth826595345/article/details/9208771
Directly on the code, comment commentary:
TextView ttext= (TextView) Findviewbyid (r.id.textv_name); The 1th type: Ttext.settextcolor (Android.graphics.Color.RED);//system comes with the color class The 2nd type: Ttext.settextcolor (0XFFFF00FF);//0xffff00ff is the data of type int, group the 0x|ff|ff00ff,0x is the mark that represents the color integer, FF is the transparency, the FF00FF represents the color, Note: Here ffff00ff must be a color representation of 8, do not accept ff00ff color representation of this 6. The 3rd type: Ttext.settextcolor (Android.graphics.Color.parseColor ("#87CEFA")); or using the color class; The 4th type: Ttext.settextcolor (This.getresources (). GetColor (r.color.red)); /* Set up by obtaining a resource file. Depending on the situation r.color.red can also be r.string.red or r.drawable.red, * It is necessary to make the corresponding configuration in the corresponding configuration file, such as (XML tag): * * << Span class= "title" >color name= "red" > #FF0000 < /color> <drawable name= "red" > #FF0000 </drawable> <string name= "red" > #FF0000 </string >*/
Android Four ways to set the background color of controls (and TextView text colors) in code