/*** How to set the color of layout control in code * Reference: *http://yahaitt.iteye.com/blog/454615 * http://blog.csdn.net/fantianheyey/article/details/9208771 * http://txlong-onz.iteye.com/blog/1249609 * http://my.oschina.net/u/2320057/blog/549507 * http://blog.csdn.net/shulianghan/article/details/19913755 */@Override Public voidInitdatas () {//system comes with the color classTvcolortext.settextcolor (Color.green); //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,//FF00FF represents color, note: Here 0xff-ff-00-ff must be 8 color representation, do not accept ff00ff this 6 color representation. Tvcolortext.settextcolor (0xFFCCCCCC); Tvcolortext.settextcolor (Color.rgb (55, 55, 55)); Tvcolortext.settextcolor (Color.parsecolor ("#87CEFA")); //set up by getting a resource file//can reference a color attribute in a resource file//<color name= "Red" > #FF0000 </color>//<drawable name= "Red" > #FF0000 </drawable>//<string name= "Red" > #FF0000 </string>Tvcolortext.settextcolor (Getresources (). GetColor (r.color.coloraccent)); }
Android resource file access and usage