Skip to content
This repository was archived by the owner on Apr 19, 2018. It is now read-only.

Commit 40af4ad

Browse files
committed
Fixed #364 that the stroke width did not join to calculation of circle center and layout width and height.
1 parent 4b78425 commit 40af4ad

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

library/src/main/java/com/viewpagerindicator/CirclePageIndicator.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ protected void onDraw(Canvas canvas) {
240240
}
241241

242242
final float threeRadius = mRadius * 3 + mGap;
243-
final float shortOffset = shortPaddingBefore + mRadius;
244-
float longOffset = longPaddingBefore + mRadius;
243+
final float shortOffset = shortPaddingBefore + mRadius + mPaintStroke.getStrokeWidth() / 2;
244+
float longOffset = longPaddingBefore + mRadius + mPaintStroke.getStrokeWidth() / 2;
245245
if (mCentered) {
246246
longOffset += ((longSize - longPaddingBefore - longPaddingAfter) - (count * threeRadius - mRadius - mGap)) / 2.0f;
247247
}
@@ -481,7 +481,8 @@ private int measureLong(int measureSpec) {
481481
//Calculate the width according the views count
482482
final int count = mViewPager.getAdapter().getCount();
483483
result = (int)(getPaddingLeft() + getPaddingRight()
484-
+ (count * (2 * mRadius + 1)) + (count - 1) * (mRadius + mGap));
484+
+ (count * (2 * mRadius + 1)) + (count - 1) * (mRadius + mGap)
485+
+ mPaintStroke.getStrokeWidth()); // The first circle half stroke + the last one half stroke
485486
//Respect AT_MOST value if that was what is called for by measureSpec
486487
if (specMode == MeasureSpec.AT_MOST) {
487488
result = Math.min(result, specSize);
@@ -507,7 +508,8 @@ private int measureShort(int measureSpec) {
507508
result = specSize;
508509
} else {
509510
//Measure the height
510-
result = (int)(2 * mRadius + getPaddingTop() + getPaddingBottom() + 1);
511+
result = (int)(2 * mRadius + getPaddingTop() + getPaddingBottom() + 1
512+
+ mPaintStroke.getStrokeWidth()); // The first circle half stroke + the last one half stroke
511513
//Respect AT_MOST value if that was what is called for by measureSpec
512514
if (specMode == MeasureSpec.AT_MOST) {
513515
result = Math.min(result, specSize);

0 commit comments

Comments
 (0)