Multiline `ReplacementSpan` Drawing Issue
Solution 1:
Flowing onto a new line is, evidently, something that ReplacementSpan
cannot do. Here is a quote from an article Drawing a rounded corner background on text by Florina Muntenescu who blogs about spans and the like. (Emphasis in the following quote is mine.)
We need to draw a drawable together with the text. We can implement a custom ReplacementSpan to draw the background and the text ourselves. However ReplacementSpans cannot flow into the next line, therefore we will not be able to support a multi-line background. They would rather look like Chip, the Material Design component, where every element must fit on a single line.
This is the issue that you are having. The article goes on about a possible solution that you may want to look into. For example, it may be possible to use some of the techniques outlined in the article to define multiple ReplacementSpans
dependent upon line breaks like is done with the background drawables.
There are other span types that may be more congenial to your purposes. Here is list of them.
Post a Comment for "Multiline `ReplacementSpan` Drawing Issue"