Skip to content

Commit ebf1dd2

Browse files
authored
Merge pull request #4 from Sonphil/master
Center progress text in CircleProgressView
2 parents 40064f7 + 6f8422e commit ebf1dd2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

MaterialProgressView-master/library/src/main/java/com/moos/library/CircleProgressView.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,10 @@ private void drawProgressText(Canvas canvas){
337337
mTextPaint.setColor(mProgressTextColor);
338338
mTextPaint.setTextAlign(Paint.Align.CENTER);
339339

340-
String progressText = ((int) moveProgress)+ "%";
341-
canvas.drawText(progressText, (getWidth() - getPaddingLeft())/2 , (getHeight() - getPaddingTop())/2, mTextPaint);
340+
String progressText = ((int) moveProgress) + "%";
341+
float x = (getWidth() + getPaddingLeft() - getPaddingRight()) / 2;
342+
float y = (getHeight() + getPaddingTop() - getPaddingBottom() - (mTextPaint.descent() + mTextPaint.ascent())) / 2;
343+
canvas.drawText(progressText, x , y, mTextPaint);
342344

343345
}
344346

0 commit comments

Comments
 (0)