Using this example, I implemented my own RoundedBackgroundSpan.
The problem is that I need to add some padding to the background, so I'm using spaces (" "), and when the spanned string happens to be the last string on the row, last spaces are ignored.
I checked and in the overriden draw function, the end value is exactly 2 characters smaller (for the two ignored spaces).
If after the spaces I add any other character, the background gets spanned correctly.
Any ideas?