textcolor - how to create textview link without underscore in android -
i came wired situation, code follow
linearlayout ll = new linearlayout(this); textview tv = new textview(this); ll.addview(tv); tv.settext(html.fromhtml("<a style=\"text-decoration:none;\" href=\"" + stringescapeutils.escapejava(elem.getchildtext("newslink")) + "\">" + stringescapeutils.escapejava(elem.getchildtext("title")) + "</a>")); tv.settextcolor(color.black);
but style="text-decoration:none"
, tv.settextcolor(color.black)
both not working, link still in blue underscore, hints on why they're not working? thanks!
you can try this. such as
string content = "your <a href='http://some.url'>html</a> content";
here concise way remove underlines hyperlinks:
spannable s = (spannable) html.fromhtml(content); (urlspan u: s.getspans(0, s.length(), urlspan.class)) { s.setspan(new underlinespan() { public void updatedrawstate(textpaint tp) { tp.setunderlinetext(false); } }, s.getspanstart(u), s.getspanend(u), 0); } tv.settext(s);
Comments
Post a Comment