热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

fromhtml不适合span。-Html.fromHtmlnotworkingforspan

IhaveaTextViewandIwanttoshowmulti-coloredtextinthat.Iamusinghtml.fromHtmlforthis,

I have a TextView and I want to show multi-colored text in that. I am using html.fromHtml for this, but it is not showing any color.

我有一个TextView,我想显示多色文本。我正在为此使用html.fromHtml,但它没有显示任何颜色。

My code is:

我的代码是:

//statusToShow is a String
Log.d("html ==>", statusToShow) ;
RStatus.setText(Html.fromHtml(statusToShow),
TextView.BufferType.SPANNABLE);

Value from Log is:

从日志值:

C P E D

mso - fareast - font - family:宋体;mso - bidi - font - family: " times new roman "; mso - bidi - theme - font

2 个解决方案

#1


2  

Try using Spannable like this:

试着像这样使用Spannable:

Spannable WordtoSpan = new SpannableString("Text To Span");

WordtoSpan.setSpan(new BackgroundColorSpan(Color.BLUE), 0, 4,
            Spannable.SPAN_INCLUSIVE_INCLUSIVE);

This will make the background color of Text Blue.

这将使文本蓝色的背景颜色。

Hope this helps.

希望这个有帮助。

#2


5  

Not all tags are supported, list of supported tags is here: http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html

并不是所有的标签都是支持的,支持的标签列表在这里:http://commonsware.com/blog/android/2010/05/26/html -tags-support -by-textview.html。


推荐阅读
author-avatar
爱死猪猪侠110_338
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有