How to Color part of TextView in Android
1 min readMay 18, 2020
Use HTML-escapes + Html.fromHtml()
The trick here is to add HTML Tags for styling in the String and then set that String to TextView.
Code:
Keep the string in string (resource)folder like this:
Read the string from string (resource)folder like this
String text = this.getResources().getString(R.string.textFromRes);
htmlText.setText(Html.fromHtml(text));
Output:
Note: The string shown in the above output looks like this
Putting up content takes a lot of time and effort 😓.
👏 clap 👏 If you think you learned something from this article.You can find me on Stackoverflow,Github,and,on Linkedin.
Give feedback and feel free to correct mistakes.