android 按钮按下时改变字体颜色
(2012-06-01 14:55:44) 标签: it |
1.新建 drawable/button_font_style.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>
2.添加至需要的xml里
<android:textColor="@drawable/button_font_style">
这里不是转载的:
一些代码设置控件颜色的东西:
textView.setTextColor(R.color.textColor_black);
如上,直接这样写是不行的
要从resources中获取 ,颜色设置必须通过Color类来操作 不然设置无效
1、textView.textViewsetTextColor(this.getResources().getColor(R.color.textColor_black));
2、textView.setTextColor(android.graphics.Color.WHITE);