+ 2

How to give a custom color to a words in edittext in android

How can I make EdiText (in android studio) to color only html tag eg Html, h1, br....., Like sololearn

27th Oct 2020, 2:21 PM
Rohit
Rohit - avatar
3 Respostas
+ 1
What about spannable textview; String word="Red Color"; Spannable spannable = new SpannableString(word); spannable.setSpan(new ForegroundColorSpan(Color.RED), 0, 3,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); EditText.setText(spannable); //This will paint(Red) first 3 Charecter of the word I think there are several other way to do this more efficiently. You can try other ways too, depends upon your problem.
28th Oct 2020, 6:56 AM
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
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ I want to make a Edittext like a code editor , as sololearn provide for html code , so when I write a html code it should be customized to its proper color how can I achieved this
28th Oct 2020, 8:59 PM
Rohit
Rohit - avatar
+ 1
Rohit I think you need an external libraries(code view) has some of features like automatic Syntex highlighting and wrapping line number e.t.c. And I don't think it will satisfy you(probably you can find a better one). https://github.com/kbiakov/CodeView-Android Making a better one without using any library than it will be a hard working task. And I dare to say that it's all for your project #betterThanSololearn. There's a lot of challenges waiting for you. But you need to learn extra about material design (some of design sololearn uses like CollapsingToolbar, view pager, bottom navigation (for home activity), drawer layout, bottom sheets (writing comments and answer), some custom material dialogue etc). You can simply ask any question if you have any problems. Note: My first mentioned answer can help you to highlight text, Links and help to set clicklistners in texts, for i.g your name is highlighted in this answer because I mentioned you. if you click to that text than it will open your profile.
29th Oct 2020, 1:35 AM
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