突出在Android中使用Html.fromHtml()文本颜色? [英] Highlighting Text Color using Html.fromHtml() in Android?

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

问题描述

我开发一个应用程序中会出现一个搜索屏幕 在这里用户可以搜索特定的关键字,而关键字应该是 突出显示。我发现Html.fromHtml方法。

I am developing an application in which there will be a search screen where user can search for specific keywords and that keyword should be highlighted. I have found Html.fromHtml method.

不过,我会想知道是否做它的正确方法或 不是。

But I will like to know whether its the proper way of doing it or not.

请让我知道你对此事的看法。

Please let me know your views on this.

推荐答案

或远不是处理 Spannable 手动S,因为你没有说你要更简单背景突出,只是文本:

Or far simpler than dealing with Spannables manually, since you didn't say that you want the background highlighted, just the text:

String styledText = "This is <font color='red'>simple</font>.";
textView.setText(Html.fromHtml(styledText), TextView.BufferType.SPANNABLE);

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

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