Android 代码中设置字体颜色
来源:互联网 发布:java const 参数 编辑:程序博客网 时间:2024/05/18 01:49
方法一:
TextView tv = new TextView(this);tv.setText("Test set TextView's color.");//方案一:代码中通过argb值的方式tv.setTextColor(Color.rgb(255, 255, 255));
方法二:
Resources resource = (Resources) getBaseContext().getResources();ColorStateList csl = (ColorStateList) resource.getColorStateList(R.color.my_color);if (csl != null) {tv.setTextColor(csl);}方法三:
在xml中先设置好color的值
XmlResourceParser xrp = getResources().getXml(R.color.my_color);try {ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp);tv.setTextColor(csl);} catch (Exception e) {}
0 0
- Android 代码中设置字体颜色
- Android 代码中设置TextView字体颜色
- Android中设置字体颜色
- android中 字体颜色设置
- Android在代码中设置textview字体颜色
- 在代码中设置设置字体颜色
- android 代码设置Button字体颜色
- Android 代码设置TextView 字体颜色--ColorStateList
- 代码中设置TextView字体颜色
- 代码设置字体颜色
- 代码设置字体颜色
- android中actionBar中字体颜色设置
- android中actionBar中字体颜色设置
- android中actionBar中字体颜色设置
- Android中TextView中设置字体颜色
- android中字体颜色的设置
- Android中字体颜色的设置
- Android中字体颜色的设置
- [ jQuery] 你还在使用jquery的click(),bind()方法么?
- 听见向日葵的微笑
- linux 中进程及任务管理命令
- 1071:验证角谷猜想
- Eclipse安装CDT开发C/C++
- Android 代码中设置字体颜色
- 程序员编程艺术第三十八章:Hero在线编程判题、出题系统的演进与优化
- Mysql or Mongodb LBS快速实现方案
- Checkstyle 系列之安装 Checkstyle
- win7下建立无线局域网
- 安装ADT-20.0.3的时候产生org.eclipse.cdt.feature.group 0.0.0' but it could not be ..
- oc中数据库使用详细解释(一)
- 1070:寻找第二小的数
- UVALive - 3305 Tour 双调欧几里得旅行商问题