1. Android设置文本颜色的4种方法:

(1)利用系统自带的颜色类:

tv.setTextColor(android.graphics.Color.RED);

(2)数字颜色表示:

tv.setTextColor(0xffff00ff);

(3)自定义颜色:

 <?xml version="1.0" encoding="utf-8"?>
<resources> <drawable name="dkgray">#80808FF0</drawable> <drawable name="yello">#F8F8FF00</drawable>
<drawable name="white">#FFFFFF</drawable>
<drawable name="darkgray">#938192</drawable>
<drawable name="lightgreen">#7cd12e</drawable>
<drawable name="black">#ff000000</drawable>
<drawable name="blue">#ff0000ff</drawable>
<drawable name="cyan">#ff00ffff</drawable>
<drawable name="gray">#ff888888</drawable>
<drawable name="green">#ff00ff00</drawable>
<drawable name="ltgray">#ffcccccc</drawable>
<drawable name="magenta">#ffff00ff</drawable>
<drawable name="red">#ffff0000</drawable>
<drawable name="transparent">#00000000</drawable>
<drawable name="yellow">#ffffff00</drawable>
</resources>

根据个人需要,颜色可以自行添加。 

在Java中设置: 

tx.setTextColor(tx.getResources().getColor(R.drawable.red)); 

color.xml中也可用color标签:

<color name="red">#ffff0000</color>     

Java中设置相应改为: 

tx.setTextColor(tx.getResources().getColor(R.color.red));

(4)直接在xml的TextView中设置:

android:textColor="#f8f8ff00"

或者

android:textColor="#f8ff00"

最新文章

  1. Pycharm使用问题# 程序界面出现方框字符
  2. 怎样实现Web控件文本框Reset的功能
  3. rac 11g_第二个节点重启后无法启动实例:磁盘组dismount问题
  4. 我给女朋友讲编程html系列(2) --Html标题标签h1
  5. iOS-NSOperation多线程
  6. PL/SQL Developer 使用中文条件查询时无数据的解决方法
  7. C++文件操作详解(ifstream、ofstream、fstream)
  8. bzoj1222: [HNOI2001]产品加工
  9. Swift 字符串连接
  10. mybatis里面的 #{}和${}
  11. 拦截QWebView弹出窗口
  12. java中String类型的相关知识
  13. Angular - 预加载 Angular 模块
  14. 【ASP.NET MVC系列】浅谈NuGet在VS中的运用
  15. 关于STM32的延时问题
  16. require &#39;./ex25&#39; can&#39;t load such file
  17. ArrayBlockingQueue简介
  18. 实验二 Java面向对象程序设计实验报告
  19. js---数组排序法(冒泡排序;快速排序)
  20. unity3d 摄像机抖动效果 CameraShake

热门文章

  1. MongoDB官方C#驱动的AsQueryable踩到坑了
  2. ue4 character 物理测试
  3. 洛谷P3431 [POI2005]AUT-The Bus
  4. c语言的小问题
  5. 3分钟了解HTTP的基础概念
  6. ES6新特性使用小结(二)
  7. .Net Core 做请求监控NLog
  8. 无线网路由器的dBm值
  9. c++笔记1
  10. ASP.Net 页面和后台执行的先后顺序