[英]Highlight the textcolor in android html.fromHtml
I have to develop one android application. 我必须开发一个Android应用程序。
I have to display the textview using html.fromHtml . 我必须使用html.fromHtml显示textview。
Here this is my content: 这是我的内容:
**Hottie Mallika Sherawat speaks about the men whom she’s over the moon about**
In these text ,have aligned on html file like below: 在这些文本中,已在html文件上对齐如下:
<span style="color:#ff8c00;">Mallika Sherawat </span>
I have to highlight the that color on Mallika Sherawat text only on my android textview also. 我必须在我的android textview上突出显示Mallika Sherawat文本上的那种颜色。
How can i do ??? 我能怎么做 ???
I have wrote below code: 我写了下面的代码:
String fullcontent = in.getStringExtra("FullContent");
full_content = fullcontent.substring(1);
lblContent = (TextView) findViewById(R.id.title1);
lblContent.setText(Html.fromHtml(full_content),TextView.BufferType.SPANNABLE);
Here the html.fromHtml is supported b,p,italic text..But why it is not supported for highlight the particular text ??? 这里html.fromHtml支持b,p,斜体文本..但是为什么不支持突出显示特定文本??? pls how can i do ??? 请问我该怎么办?
Here's a list of html tags supported by textview 这是textview支持的html标签列表
http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html
For using SpannableString 用于使用SpannableString
http://www.chrisumbel.com/article/android_textview_rich_text_spannablestring http://www.chrisumbel.com/article/android_textview_rich_text_spannablestring
Example: 例:
Using Spannable String 使用Spannable字符串
_tv.setText("");
SpannableString ss1= new SpannableString(s);
ss1.setSpan(new StyleSpan(Typeface.BOLD), 0, 23, 0);
ss1.setSpan(new StyleSpan(Typeface.ITALIC), 0, 23, 0);
ss1.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 23, 0);
_tv.setText(ss1);
Using Html 使用Html
String text = "<font color=#cc0029>hello</font> <font color=#ffcc00>world</font>";
yourtextview.setText(Html.fromHtml(text));
Try this... 尝试这个...
String styledText = "This is <font color='red'>simple</font>.";
textView.setText(Html.fromHtml(styledText), TextView.BufferType.SPANNABLE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.