android 画一对漂亮的括号。是()() 这种括号。注意是在canvas上画出来的 ,不是用字符代替的。
这是因为我需要根据需要不同尺寸的括号。但是用drawArc画出的括号很丑。以下是主要代码。如何才能画一个比较漂亮的括号呢。
public static final int bracketWidth = ViewTools.dip2px(7);
private static Paint bracketPaint = new Paint();
static {
bracketPaint.setStrokeWidth(ViewTools.dip2px(1.5f));
bracketPaint.setStyle(Paint.Style.STROKE );
}
public static void drawLeftBracket(Canvas canvas, int x, int y, int height) {
x += bracketWidth / 2;
RectF rect = new RectF(x, y, x + bracketWidth, y + height);
canvas.drawArc(rect, 90, 180, false, bracketPaint);
}