Reputation: 23787
I ran my code on my Nexus 7 whilst it still had Android 4.3 installed. I then upgraded to Android 4.4 and ran my code again. Below are my findings on a weird Canvas.drawArc() / Path.arcTo() bug (graphics glitch) ...
First Method
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
//draw Background
canvas.drawRect(mOuterArcRectangle, mBackgroundPaint);
//draw arc
Path path = new Path();
path.arcTo(mInnerArcRectangle, mAngleStart, mSweep);
canvas.drawPath(path, mPaint);
}
State
mOuterArcRectangle = RectF(0.0, 0.0, 1080.0, 1080.0)
mInnerArcRectangle = RectF(150.0, 150.0, 930.0, 930.0)
mAngleStart = 120
mSweep = 135
causes this result...
2nd method
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
//draw Background
canvas.drawRect(mOuterArcRectangle, mBackgroundPaint);
//draw arc
canvas.drawArc(mInnerArcRectangle, mAngleStart, mSweep, false, mPaint);
}
State
mOuterArcRectangle = RectF(0.0, 0.0, 1080.0, 1080.0)
mInnerArcRectangle = RectF(150.0, 150.0, 930.0, 930.0)
mAngleStart = 120
mSweep = 135
causes this result...
On Android 4.4 Either method results in (what I would consider successful)
Solution ? Is there a workaround for this problem? Is it a known problem ?
Upvotes: 2
Views: 996
Reputation: 23787
I've fixed it simply by adding 0.5f
to the sweep angle before drawing the arc.
Upvotes: 2