【发布时间】:2016-06-03 06:17:43
【问题描述】:
嗨,我在弧线的两端(开始和结束)上画点有困难
虽然我可以在画布上画弧线。这是我绘制圆弧的示例代码。
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
float width = (float) getWidth();
float height = (float) getHeight();
float radius;
if (width > height) {
radius = height / 4;
} else {
radius = width / 4;
}
float center_x, center_y;
final RectF oval = new RectF();
center_x = width / 2;
center_y = height / 2;
oval.set(center_x - radius,
center_y - radius,
center_x + radius,
center_y + radius);
float percent = 25;
float arcRadius = 360;
float angle = arcRadius * (percent/100);
canvas.drawArc(oval, 270, 360, false, trackpaint);
canvas.drawArc(oval, 270, angle, false, arcPaint);
}
唯一缺少的是将圆放在弧的起点和终点。我试过这个链接,但它不起作用Calculate Arc Center Point, Knowing It's Start and End Degrees。任何帮助都感激不尽。谢谢
【问题讨论】:
标签: android view draw android-custom-view ondraw