titleView.setTextColor(Color.BLUE);
很多时候都需要用在Java代码中去更改字体的颜色,密码的显示方式,以及使用java代码创建一个控件、一个布局,这次遇到的问题就是使用java代码更改字体的颜色,第一次使用的是
[java] view plain copy
// tvAbcAccount.setTextColor(color.PressAccountTextColor);
// tvVBcdAccount.setTextColor(color.AccountTextColor);
PressAccountTextColor和AccountTextColor是在colorlist.xml中定义的两种颜色值
[java] view plain copy
#b5b5b5
#e7e7e7
目的是当有按键被按下的时候就对字体颜色进行相应的改变,但是上述代码不能达到想要的结果,后来查找了一下资料,改为
tvAbcAccount.setTextColor(getResources().getColor(R.color.PressAccountTextColor));
tvBcdAccount.setTextColor(getResources().getColor(R.color.AccountTextColor));