Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set color of UnderlineSpan?

This question is a follow up to my last question: How to highlight text like Android spell-checker?

I'm using an UnderlineSpan to underline text in an EditText but I need the underline to be IN COLOR like this screen shot of the spelling checker:

enter image description here

like image 326
Barry Fruitman Avatar asked Jan 26 '13 02:01

Barry Fruitman


1 Answers

Unfortunately, you can't do this solely with a Span -- there are no public methods to do what you ask. There is a method to set the underline color in TextPaint independent of the text color (you can see it in the source code for SuggestionSpan) but it's hidden.

If you can get access to the EditText, you can handle the Span and draw the underline yourself, but otherwise you are out of luck.

like image 63
Lisa Wray Avatar answered Sep 20 '22 00:09

Lisa Wray