在阅读了有关C#转换器的帮助之后,我想到了这个。我仍然需要做一些调整,但是如果有人也在寻找类似的答案。
public class RoundedBackgroundSpan extends ReplacementSpan{ @Override public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) { return 0; } @Override public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { RectF rect = new RectF(x, top, x + text.length(), bottom); paint.setColor(Color.CYAN); canvas.drawRoundRect(rect, 20, 20, paint); paint.setColor(Color.WHITE); canvas.drawText(text, start, end, x, y, paint); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)