From 48a10a1996c8334ffc6e68ccfb2e49678c8b06d7 Mon Sep 17 00:00:00 2001 From: Yuriy Budiyev Date: Thu, 30 Nov 2017 18:11:32 +0300 Subject: [PATCH] Dev --- .../CircularProgressBar.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/budiyev/android/circularprogressbar/CircularProgressBar.java b/src/main/java/com/budiyev/android/circularprogressbar/CircularProgressBar.java index 4ce4ab1..5348f22 100644 --- a/src/main/java/com/budiyev/android/circularprogressbar/CircularProgressBar.java +++ b/src/main/java/com/budiyev/android/circularprogressbar/CircularProgressBar.java @@ -236,21 +236,23 @@ private void invalidateDrawRect() { } private void invalidateDrawRect(int width, int height) { - int size; + float thickness; if (mDrawBackgroundStroke) { - size = Math.round( - Math.max(mForegroundStrokePaint.getStrokeWidth(), mBackgroundStrokePaint.getStrokeWidth())); + thickness = Math.max(mForegroundStrokePaint.getStrokeWidth(), mBackgroundStrokePaint.getStrokeWidth()); } else { - size = Math.round(mForegroundStrokePaint.getStrokeWidth()); + thickness = mForegroundStrokePaint.getStrokeWidth(); } if (width > height) { - int space = (width - height) / 2; - mDrawRect.set(space + size / 2 + 1, size / 2 + 1, width - space - size / 2 - 1, height - size / 2 - 1); + float offset = (width - height) / 2f; + mDrawRect.set(offset + thickness / 2f + 1f, thickness / 2f + 1f, width - offset - thickness / 2f - 1f, + height - thickness / 2f - 1f); } else if (width < height) { - int space = (height - width) / 2; - mDrawRect.set(size / 2 + 1, space + size / 2 + 1, width - size / 2 - 1, height - space - size / 2 - 1); + float offset = (height - width) / 2f; + mDrawRect.set(thickness / 2f + 1f, offset + thickness / 2f + 1f, width - thickness / 2f - 1f, + height - offset - thickness / 2f - 1f); } else { - mDrawRect.set(size / 2 + 1, size / 2 + 1, width - size / 2 - 1, height - size / 2 - 1); + mDrawRect.set(thickness / 2f + 1f, thickness / 2f + 1f, width - thickness / 2f - 1f, + height - thickness / 2f - 1f); } }