I have a partial solution suggesting a background color. The only way I did this (other than writing my own span class) is to display the image in a LayerList on top of the GradientDrawable , which is your background color. In code, it could be something like this:
// Assume that d is the image drawable and bgSpan is the background color span. // Then instead of doing // ImageSpan imgSpan = new ImageSpan(d, ImageSpan.ALIGN_BASELINE); // you do the following: GradientDrawable gd = new GradientDrawable(); gd.setShape(GradientDrawable.RECTANGLE); gd.setColor(bgSpan.getBackgroundColor()); LayerDrawable ld = new LayerDrawable(new Drawable[] {gd, d}); ld.setBounds(d.getBounds()); ImageSpan imgSpan = new ImageSpan(ld, ImageSpan.ALIGN_BASELINE);
You may be able to use the same trick to simulate underlining (adding another picture to the list of layers). However, I have not experimented with this and cannot offer a concrete proposal.
source share