Android: Adding Padding to BackgroundColorSpan
Anton L.
582

Thanks! This was exactly what I needed.

I did notice that “setShadowLayer” is extremely slow. I ended up expanding the rectangle that you draw on canvas, which is a lot faster.

p.setColor(mBackgroundColor);
Rect rect = new Rect();
c.getClipBounds(rect);
rect.inset(-padding, 0);
c.clipRect(rect, Region.Op.REPLACE);
c.drawRect(mBgRect, p);
p.setColor(paintColor);
Show your support

Clapping shows how much you appreciated Bart Nijland’s story.