+ 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

25th Jan 2021, 9:45 AM
Saurya
Saurya - avatar
8 odpowiedzi
+ 8
https://code.sololearn.com/ciQPuk8N1ch0/?ref=app i have solved yet 🙂 by replacing specific text with Html class in Android studio
28th Jan 2021, 5:28 PM
Saurya
Saurya - avatar
+ 6
By creating a method if specific Word found in Text then replace that Specific text with Html.fromhtml() method
28th Jan 2021, 5:36 PM
Saurya
Saurya - avatar
+ 6
then after replacing from Html class in color set text in TextView
28th Jan 2021, 5:42 PM
Saurya
Saurya - avatar
+ 2
"Spanneble" See the Android official.
28th Jan 2021, 5:25 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 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.
28th Jan 2021, 5:31 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 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.
28th Jan 2021, 5:49 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 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="&lt;span style=color:blue&gt;hello&lt;/span&gt; &lt;span style=color:red&gt;this&lt;/span&gt; &lt;span style=color: white&gt;is example&lt;/span&gt; &lt;span style=color: green&gt;of text&lt;/span&gt;" Type="html" /> This code provide same result as you expect
27th Jan 2021, 4:22 AM
Shashank Mishra
Shashank Mishra - avatar
+ 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.
28th Jan 2021, 6:11 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar