summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/component_selector.xml5
-rw-r--r--res/values/vpi__attrs.xml2
-rw-r--r--res/values/vpi__defaults.xml1
-rw-r--r--src/com/viewpagerindicator/CirclePageIndicator.java12
4 files changed, 14 insertions, 6 deletions
diff --git a/res/layout/component_selector.xml b/res/layout/component_selector.xml
index fadf2ee..a33eeb0 100644
--- a/res/layout/component_selector.xml
+++ b/res/layout/component_selector.xml
@@ -27,7 +27,10 @@
android:id="@+id/page_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="5dp"
+ android:paddingTop="8dp"
+ themes:radius="4dp"
+ themes:spacing="16dp"
+ themes:pageColor="@android:color/transparent"
themes:fillColor="@android:color/white"/>
</FrameLayout>
diff --git a/res/values/vpi__attrs.xml b/res/values/vpi__attrs.xml
index dbe72a2..e197d07 100644
--- a/res/values/vpi__attrs.xml
+++ b/res/values/vpi__attrs.xml
@@ -41,6 +41,8 @@
<attr name="android:orientation"/>
<!-- Radius of the circles. This is also the spacing between circles. -->
<attr name="radius" format="dimension" />
+ <!-- Spacing from center to center for each indicator -->
+ <attr name="spacing" format="dimension" />
<!-- Whether or not the selected indicator snaps to the circles. -->
<attr name="snap" format="boolean" />
<!-- Color of the open circles. -->
diff --git a/res/values/vpi__defaults.xml b/res/values/vpi__defaults.xml
index b6c10dd..f1da62c 100644
--- a/res/values/vpi__defaults.xml
+++ b/res/values/vpi__defaults.xml
@@ -23,6 +23,7 @@
<color name="default_circle_indicator_page_color">#808184</color>
<integer name="default_circle_indicator_orientation">0</integer>
<dimen name="default_circle_indicator_radius">3dp</dimen>
+ <dimen name="default_circle_indicator_spacing">12dp</dimen>
<bool name="default_circle_indicator_snap">false</bool>
<color name="default_circle_indicator_stroke_color">#FFDDDDDD</color>
<dimen name="default_circle_indicator_stroke_width">1dp</dimen>
diff --git a/src/com/viewpagerindicator/CirclePageIndicator.java b/src/com/viewpagerindicator/CirclePageIndicator.java
index 8310d58..b4b439a 100644
--- a/src/com/viewpagerindicator/CirclePageIndicator.java
+++ b/src/com/viewpagerindicator/CirclePageIndicator.java
@@ -58,6 +58,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
private int mOrientation;
private boolean mCentered;
private boolean mSnap;
+ private float mSpacing;
private int mTouchSlop;
private float mLastMotionX = -1;
@@ -87,6 +88,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);
+ final float defaultSpacing = res.getDimension(R.dimen.default_circle_indicator_spacing);
//Retrieve styles attributes
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);
@@ -102,6 +104,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);
+ mSpacing = a.getDimension(R.styleable.CirclePageIndicator_spacing, defaultSpacing);
Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
if (background != null) {
@@ -228,11 +231,10 @@ public class CirclePageIndicator extends View implements PageIndicator {
shortPaddingBefore = getPaddingLeft();
}
- final float threeRadius = mRadius * 3;
final float shortOffset = shortPaddingBefore + mRadius;
float longOffset = longPaddingBefore + mRadius;
if (mCentered) {
- longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - ((count * threeRadius) / 2.0f);
+ longOffset += ((longSize - longPaddingBefore - longPaddingAfter) / 2.0f) - ((count * mSpacing) / 2.0f);
}
float dX;
@@ -245,7 +247,7 @@ public class CirclePageIndicator extends View implements PageIndicator {
//Draw stroked circles
for (int iLoop = 0; iLoop < count; iLoop++) {
- float drawLong = longOffset + (iLoop * threeRadius);
+ float drawLong = longOffset + (iLoop * mSpacing);
if (mOrientation == HORIZONTAL) {
dX = drawLong;
dY = shortOffset;
@@ -265,9 +267,9 @@ public class CirclePageIndicator extends View implements PageIndicator {
}
//Draw the filled circle according to the current scroll
- float cx = (mSnap ? mSnapPage : mCurrentPage) * threeRadius;
+ float cx = (mSnap ? mSnapPage : mCurrentPage) * mSpacing;
if (!mSnap) {
- cx += mPageOffset * threeRadius;
+ cx += mPageOffset * mSpacing;
}
if (mOrientation == HORIZONTAL) {
dX = longOffset + cx;