Multiple Text Color in Single TextView
How to Show specific text in Color Text = hello this is example of text need output like this = hello : in blue color this : in red color is example : white color of text : green color like IDE and Code Editor i wanna this kind of Text in my Android Studio project
1/25/2021 9:45:10 AMSaurya
8 AnswersNew Answer
https://code.sololearn.com/ciQPuk8N1ch0/?ref=app i have solved yet 🙂 by replacing specific text with Html class in Android studio
"Spanneble" See the Android official.
Saurya ya, seems like good solution using HTML spans, but is that dynamic, how you gonna change or perform action with those TextView in runtime.
Saurya seems ligit to me, I'm not really into html classs. Is this only for text markup or have other usefulness, how about complex text highlighting, a text which acts as button or so on. Don't get me wrong, seriously I'm not downvoting your answers.
You can do it by html encode I am giving a example in xamarin android Example <span style=color:blue>hello</span> <span style=color:red>this</span> <span style=color: white>is example</span> <span style=color: green>of text</span> <Lable Text="<span style=color:blue>hello</span> <span style=color:red>this</span> <span style=color: white>is example</span> <span style=color: green>of text</span>" Type="html" /> This code provide same result as you expect
By creating a method if specific Word found in Text then replace that Specific text with Html.fromhtml() method
then after replacing from Html class in color set text in TextView
Saurya simply don't delete this stuffs, as in future someone may have same problem, this might be helpful. People will learn something from this.