@@ -45,6 +45,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
4545 private static final int INVALID_POINTER = -1 ;
4646
4747 private float mRadius ;
48+ private float mGapWidth ;
4849 private final Paint mPaintPageFill = new Paint (ANTI_ALIAS_FLAG );
4950 private final Paint mPaintStroke = new Paint (ANTI_ALIAS_FLAG );
5051 private final Paint mPaintFill = new Paint (ANTI_ALIAS_FLAG );
@@ -84,6 +85,7 @@ public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
8485 final int defaultStrokeColor = res .getColor (R .color .default_circle_indicator_stroke_color );
8586 final float defaultStrokeWidth = res .getDimension (R .dimen .default_circle_indicator_stroke_width );
8687 final float defaultRadius = res .getDimension (R .dimen .default_circle_indicator_radius );
88+ final float defaultGap = res .getDimension (R .dimen .default_circle_indicator_gap );
8789 final boolean defaultCentered = res .getBoolean (R .bool .default_circle_indicator_centered );
8890 final boolean defaultSnap = res .getBoolean (R .bool .default_circle_indicator_snap );
8991
@@ -100,6 +102,7 @@ public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
100102 mPaintFill .setStyle (Style .FILL );
101103 mPaintFill .setColor (a .getColor (R .styleable .CirclePageIndicator_fillColor , defaultFillColor ));
102104 mRadius = a .getDimension (R .styleable .CirclePageIndicator_radius , defaultRadius );
105+ mGapWidth = a .getDimension (R .styleable .CirclePageIndicator_gap , defaultGap );
103106 mSnap = a .getBoolean (R .styleable .CirclePageIndicator_snap , defaultSnap );
104107
105108 Drawable background = a .getDrawable (R .styleable .CirclePageIndicator_android_background );
@@ -185,6 +188,15 @@ public float getRadius() {
185188 return mRadius ;
186189 }
187190
191+ public void setGapWidth (float gap ) {
192+ mGapWidth = gap ;
193+ invalidate ();
194+ }
195+
196+ public float getGapWidth () {
197+ return mGapWidth ;
198+ }
199+
188200 public void setSnap (boolean snap ) {
189201 mSnap = snap ;
190202 invalidate ();
@@ -227,9 +239,9 @@ protected void onDraw(Canvas canvas) {
227239 shortPaddingBefore = getPaddingLeft ();
228240 }
229241
230- final float threeRadius = mRadius * 3 ;
242+ final float threeRadius = mRadius * 3 + mGapWidth ;
231243 final float shortOffset = shortPaddingBefore + mRadius ;
232- float longOffset = longPaddingBefore + mRadius ;
244+ float longOffset = longPaddingBefore + mRadius + mGapWidth ;
233245 if (mCentered ) {
234246 longOffset += ((longSize - longPaddingBefore - longPaddingAfter ) / 2.0f ) - ((count * threeRadius ) / 2.0f );
235247 }
0 commit comments