Cannot Set Multi Text color for text view using Html.fromText in < 24

No need for HTML, just use spans.

Spannable text = new SpannableString("hello");
text.setSpan(new ForegroundColorSpan(Color.RED), 0, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
mTextView.setText(text);

If you’re using appcompat, you probably want to new AppCompatTextView(context) rather than just new TextView(context).

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top