gpt4 book ai didi

java - Android - 需要 ondraw() 示例的帮助

转载 作者:行者123 更新时间:2023-12-01 14:10:15 25 4
gpt4 key购买 nike

我使用下面的代码来绘制 View

@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);

paint.setStyle(Style.STROKE);
paint.setAntiAlias(true);
paint.setColor(BACKGROUND_COLOR);

final RectF rectl = new RectF(0,0,2* padding,getHeight());
final RectF rectr = new RectF(getWidth()-(2* padding),0,getWidth(),getHeight());

canvas.drawLine(padding, 0, getWidth()-padding, 0, paint);
canvas.drawLine(padding,getHeight()-1, getWidth()-padding, getHeight()-1, paint);
canvas.drawArc(rectl, 90, 180, true, paint);
canvas.drawArc(rectr, 270, 180, true, paint);
}

输出如下

enter image description here

但我期望,需要删除drawArc底线,像这样,

enter image description here

如何实现这一目标?

最佳答案

将drawArc的第三个参数设置为false。

useCenter表示圆弧的中心也应该连接到两端,这是半圆和D的区别。

关于java - Android - 需要 ondraw() 示例的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18567225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com