0

I've got a string containing HTML link like this:

<string name="text_with_link"><a href="openDocument://document1.html"><b>This</b></a> and <a href="openDocument://document2.html"><b>this</b></a> are links</string>

As you noticed, I want the links to be bold. That is the only formatting I want the links to have, though. However, the result looks like this:

enter image description here

How can I remove the underline and color from the link?

I've tried to add style="text-decoration:none;" in following forms

<a href="openDocument://document2.html" style="text-decoration:none;">

<a href="openDocument://document2.html" style="text-decoration:none !important;">

<style>a {text-decoration:none;}</style><a href="openDocument://document1.html"><b>This</b></a>

.. but no luck. CSS doesn't seem to work in Android strings.

Marcel Bro
  • 4,907
  • 4
  • 43
  • 70

1 Answers1

0

you will have to use Html.fromHtml for formatting to work like this:

tv = (TextView) findViewById (R.id.textviewid);       
tv.setText(Html.fromHtml(getResources.getString(R.string.text_with_link)));

also to change link color you have to use android:textColorLink property in your text view XML to change the link color.

CSS does not work in android strings.

Rahul Tiwari
  • 6,851
  • 3
  • 49
  • 78