1.JAVA代码使用工具Html.fromHtml:
String styledText = "This is <font color='red'>simple</font>.";textView.setText(Html.fromHtml(styledText), TextView.BufferType.SPANNABLE);
2.字符串处理Spannable:

TextView text = (TextView) findViewById(R.id.text_login);text.setText("");text.append("Add all your funky text in here");Spannable text = (Spannable) text.getText();text.setSpan(new BackgroundColorSpan(Color.RED), 1, 4, 0);

3.使用颜色值从XML资源:
int сolor = getResources().getColor(R.color.label_color);String сolorString = String.format("%X", labelColor).substring(2);Html.fromHtml(String.format("<font color=\"#\">text</font>", сolorString), TextView.BufferType.SPANNABLE); 
4.使用的WebView:
WebView webview = new WebView(this);String summary = "<html><body>Sorry, <span style=\"background:red;\">Madonna</span> gave no results</body></html>";webview.loadData(summary, "text/html", "utf-8");

更多相关文章

  1. Android TextView 个别文字字体颜色格式
  2. 点击listitem按下效果替换默认颜色
  3. Android 字符串转换大小写
  4. android 计算字符串长度,高度
  5. Android中五大字符串总结(String、StringBuffer、StringBuilder、
  6. Android状态栏颜色修改
  7. EditText 各部分颜色设置小结

随机推荐

  1. 完美解决android Studio打开报错 https:/
  2. Android编译过程详解
  3. android发送短信
  4. Android(安卓)默认全面屏适配方案
  5. Android抽屉式按钮实现
  6. Android常用组件,太全了
  7. Android(安卓)ProgressDialog的使用
  8. Linux profilers: oprofile vs. ftrace (
  9. Android(安卓)曲线绘制Demo
  10. android中如何给button加圆角