i came into this wired situation, my code is as 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 the style="text-decoration:none"
and tv.setTextColor(color.black)
both not working, the link is still in blue with underscore, any hints on why they're not working? Thanks!
You can use
Spannable
andURLSpan
here to remove hyperlink underline from your codeFirst of all make your anchor tag text into
Spannable
Create new class
URLSpanNoUnderline
and extend it withURLSpan
and overrideupdateDrawState
method. in that method you can setsetUnderlineText
tofalse
then use this method you can remove your link
For more information you can visit this link
you can try this. such as
Here is a concise way to remove underlines from hyperlinks: