在Android的TextView中使用多种文字颜色[Html.fromhtml()] [英] Using multiple text colors in Android's textview [ Html.fromhtml() ]

查看:363
本文介绍了在Android的TextView中使用多种文字颜色[Html.fromhtml()]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个TextView中我试图分隔文本两种风格不同的话。

到目前为止,我有:

textview.setText(Html.fromHtml(< I><小><字体颜色= \c5c5c5 \>+竞争者ID:+< /字体>< /小>< / I>+<字体颜色= \47a842 \>中+ compID +< / FONT>中));

基本上,我说我想竞争者ID:是斜体,小,灰色

和我想要的字符串 compID 是正常的大小,而不是斜体,和绿色。

在code的工作完美的斜体和一小部分,但由于某些原因,整个文本视图有灰色的文字,而不仅仅是竞争者ID:

任何想法?

解决方案

  textview.setText(Html.fromHtml(< I><小><字体颜色= \ #c5c5c5 \>+竞争者ID:+< / FONT>< /小>< / I>+<字体颜色= \#47a842 \>中+ compID + 其中&; / FONT>中));
 

试试上面的。

In one textview I'm trying to separate text stylings on different words.

So far I have:

textview.setText(Html.fromHtml("<i><small><font color=\"c5c5c5\">" + "Competitor ID: " + "</font></small></i>" + "<font color=\"47a842\">" + compID + "</font>"));

Basically, I'm saying I want "Competitor ID:" to be italic, small, and grey.

And I want that string compID to be normal sized, not italic, and green.

The italic and small portions of the code work perfectly, but for some reason, the entire text view has grey text, rather than just "Competitor ID:".

Any ideas?

解决方案

textview.setText(Html.fromHtml("<i><small><font color=\"#c5c5c5\">" + "Competitor ID: " + "</font></small></i>" + "<font color=\"#47a842\">" + compID + "</font>"));

Try the above.

这篇关于在Android的TextView中使用多种文字颜色[Html.fromhtml()]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆