Changing color of hyperlink in android
<p>My objective is to change the hyperlink from a green color to a blue color in android. Currently the whole textview is green.</p>

<p><a href="https://i.stack.imgur.com/5ynYZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ynYZ.png" alt="enter image description here"></a></p>

<p>I'm using this class to remove the underlining of the hyperlink in android - I found it on SO:</p>

<pre><code>public class TextViewNoUnderline extends AppCompatTextView {
    public TextViewNoUnderline(Context context) {
        this(context, null);
    }

    public TextViewNoUnderline(Context context, AttributeSet attrs) {
        this(context, attrs, android.R.attr.textViewStyle);
    }

    public TextViewNoUnderline(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setSpannableFactory(Factory.getInstance());
    }

    private static class Factory extends Spannable.Factory {
        private final static Factory sInstance = new Factory();

        public static Factory getInstance() {
            return sInstance;
        }

        @Override
        public Spannable newSpannable(CharSequence source) {
            return new SpannableNoUnderline(source);
        }
    }

    private static class SpannableNoUnderline extends SpannableString {
        public SpannableNoUnderline(CharSequence source) {
            super(source);
        }

        @Override
        public void setSpan(Object what, int start, int end, int flags) {
            if (what instanceof URLSpan) {
                what = new UrlSpanNoUnderline((URLSpan) what);
            }
            super.setSpan(what, start, end, flags);
        }
    }
}
</code></pre>

<p>Then in my xml I did this:</p>

<pre><code>&lt;com.myapp.customshapes.TextViewNoUnderline
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/tos"
    tools:text="@string/signing_in"/&gt;
</code></pre>

<p>Where signing_in is this string:</p>

<pre><code>&lt;string name="signing_in"&gt;&amp;lt;body link=&amp;quot;blue&amp;quot;&amp;gt;By signing in, you agree to our &amp;lt;a href=&amp;quot;com.myapp://http://www.myapp.com/Terms.html&amp;quot;&amp;gt;Terms of Service&amp;lt;/a&amp;gt;
    and &amp;lt;a href=&amp;quot;com.myapp://http://www.myapp.com/Privacy.html&amp;quot;&amp;gt;Privacy Policy&amp;lt;/a&amp;gt;&lt;/string&gt;
</code></pre>

<p>I have set this in my java class:</p>

<pre><code>    tos.setText(Html.fromHtml(getString(R.string.signing_in)));
</code></pre>

<p>As you can see, in my html, I said: <code>&lt;body link="blue"&gt;</code></p>

<p>The whole TOS which includes non-hyperlinked words and hyperlinked words is green as in the pic. Why are the hyperlinks not turning blue? </p>