I have a multiline text (TextView with multiline) and I need to draw custom underline under its part.
Whole the phrase is always on one line.
I've succeeded to do son on singleline text with ReplacementSpan, but it doesn't work for multiline.
There is a BackgroundColorSpan that almost fits the desired behaviour but it changes the background of selected text while I need to draw custom Drawable under selected phrase.
There is a LineBackgroundSpan that works for the whole line and almost the thing I need. There is a lineNumber parameter, but there is no lineCount parameter. There is nothing I can use to find the phrase position.
If there were a way to get coordinates of phrase at TextView I would place a drawable under the TextView, but I cant fint such a way too.
I've found a solution and as I see enormous interest ( :smile: ) to the problem, I will share my solution.
I've used
LineBackgroundSpanas there is information about phrase to be marked. This information is about the phrase line position, not the phrase itself, so additional information is required and passed through constructor.The code is for the simple situation when all the phrase fits onle line width. I've acheaved this by adding NBSP instead of spaces (that was acceptable and even desired in my case).