From 40af4adb5e90b63b875d57fb65a6e5dc96bc4ccb Mon Sep 17 00:00:00 2001 From: msdx <645079761@qq.com> Date: Wed, 19 Aug 2015 14:58:58 +0800 Subject: [PATCH] Fixed #364 that the stroke width did not join to calculation of circle center and layout width and height. --- .../com/viewpagerindicator/CirclePageIndicator.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/viewpagerindicator/CirclePageIndicator.java b/library/src/main/java/com/viewpagerindicator/CirclePageIndicator.java index e6072d404..c95c1aa18 100644 --- a/library/src/main/java/com/viewpagerindicator/CirclePageIndicator.java +++ b/library/src/main/java/com/viewpagerindicator/CirclePageIndicator.java @@ -240,8 +240,8 @@ protected void onDraw(Canvas canvas) { } final float threeRadius = mRadius * 3 + mGap; - final float shortOffset = shortPaddingBefore + mRadius; - float longOffset = longPaddingBefore + mRadius; + final float shortOffset = shortPaddingBefore + mRadius + mPaintStroke.getStrokeWidth() / 2; + float longOffset = longPaddingBefore + mRadius + mPaintStroke.getStrokeWidth() / 2; if (mCentered) { longOffset += ((longSize - longPaddingBefore - longPaddingAfter) - (count * threeRadius - mRadius - mGap)) / 2.0f; } @@ -481,7 +481,8 @@ private int measureLong(int measureSpec) { //Calculate the width according the views count final int count = mViewPager.getAdapter().getCount(); result = (int)(getPaddingLeft() + getPaddingRight() - + (count * (2 * mRadius + 1)) + (count - 1) * (mRadius + mGap)); + + (count * (2 * mRadius + 1)) + (count - 1) * (mRadius + mGap) + + mPaintStroke.getStrokeWidth()); // The first circle half stroke + the last one half stroke //Respect AT_MOST value if that was what is called for by measureSpec if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize); @@ -507,7 +508,8 @@ private int measureShort(int measureSpec) { result = specSize; } else { //Measure the height - result = (int)(2 * mRadius + getPaddingTop() + getPaddingBottom() + 1); + result = (int)(2 * mRadius + getPaddingTop() + getPaddingBottom() + 1 + + mPaintStroke.getStrokeWidth()); // The first circle half stroke + the last one half stroke //Respect AT_MOST value if that was what is called for by measureSpec if (specMode == MeasureSpec.AT_MOST) { result = Math.min(result, specSize);