+ 9
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
8 Antworten
+ 8
https://code.sololearn.com/ciQPuk8N1ch0/?ref=app
i have solved yet 🙂 by replacing specific text with Html class in Android studio
+ 6
By creating a method
if
specific Word found in Text then
replace that Specific text with
Html.fromhtml() method
+ 6
then after replacing from Html class in color set text in TextView
+ 2
"Spanneble"
See the Android official.
+ 2
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.
+ 2
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.
+ 1
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
+ 1
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.