I want to create Span that can modify content. So, for example i need to draw text without first 3 and last 4 characters. I'm trying to use Replacable span:
class ItalicReplacement extends ReplacementSpan {
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
paint.setTextSkewX(-0.25f);
return (int) paint.measureText(text, start + 3, end - 4);
}
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
paint.setTextSkewX(-0.25f);
canvas.drawText(text, start + 3, end - 4, x, y, paint);
}
}
But replacable span draws as an image. Not as text. So, i can't work with it as a regular text. And the main problem is wrapping (https://i.stack.imgur.com/LXJUj.png).
I saw this and this. There is the same problems.
So, it there any other way to do what i want? For example, i want to do clickable spoilers or urls that displays only domain. May other *Span can do that?