0

I want to open url using Html.fromHtml()also the particular text between tags should be green in color and not underline.

How can I do that right now I'm doing like this:

consent = consent.replace("<clickable>", "<a href=\"https://www.google.com/\"").replace("</clickable>", "</a>");
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
    consentCheck.setText(Html.fromHtml(consent, Html.FROM_HTML_MODE_LEGACY));
} else {
    consentCheck.setText(Html.fromHtml(consent));
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
blackHawk
  • 6,047
  • 13
  • 57
  • 100

1 Answers1

0

Have you tried :

textView.setMovementMethod(LinkMovementMethod.getInstance());

To change color :

String blue = "this is blue";
SpannableString blueSpannable = new SpannableString(blue);
blueSpannable.setSpan(new ForegroundColorSpan(Color.BLUE), 0, blue.length(), 0);
builder.append(blueSpannable);

mTextView.setText(builder, BufferType.SPANNABLE);
Milan Hirpara
  • 534
  • 4
  • 18
  • yes see my yesterdays question: https://stackoverflow.com/questions/49026982/how-to-make-text-underline-and-remove-text-at-the-same-time – blackHawk Mar 01 '18 at 07:50