This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onDraw(Canvas canvas) { | |
if (!mClockwise) { | |
canvas.scale(-1, 1, mArcRect.centerX(), mArcRect.centerY()); | |
} | |
// draw the text | |
String textPoint = String.valueOf(mPoints); | |
mTextPaint.getTextBounds(textPoint, 0, textPoint.length(), mTextRect); | |
// center the text | |
int xPos = canvas.getWidth() / 2 - mTextRect.width() / 2; | |
int yPos = (int)((mArcRect.centerY()) - ((mTextPaint.descent() + mTextPaint.ascent()) / 2)); | |
canvas.drawText(String.valueOf(mPoints), xPos, yPos, mTextPaint); | |
// draw the arc and progress | |
canvas.drawArc(mArcRect, ANGLE_OFFSET, 360, false, mArcPaint); | |
canvas.drawArc(mArcRect, ANGLE_OFFSET, mProgressSweep, false, mProgressPaint); | |
if (mEnabled) { | |
// draw the indicator icon | |
canvas.translate(mTranslateX - mIndicatorIconX, mTranslateY - mIndicatorIconY); | |
mIndicatorIcon.draw(canvas); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment