From 2f99951c5250f1b4eac8f67c3306e3a0d49444a5 Mon Sep 17 00:00:00 2001 From: thirstycoda Date: Sun, 6 Aug 2023 16:46:53 +0100 Subject: [PATCH 1/2] Added selectedDotDrawable customisation --- README.md | 3 ++- .../res/drawable/baseline_play_arrow_24.xml | 5 ++++ demo/src/main/res/layout/activity_main.xml | 3 ++- .../ScrollingPagerIndicator.java | 27 ++++++++++++------- .../src/main/res/values/attrs.xml | 1 + 5 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 demo/src/main/res/drawable/baseline_play_arrow_24.xml diff --git a/README.md b/README.md index 4c30cc6..943bbca 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,8 @@ indicator.attachToPager(pager, new ViewPagerAttacher()); | spi_dotMinimumSize | The minimum dot size for the corner dots. This size is lower or equal to ```spi_dotSize``` and greater or equal to the internal calculation for the corner dots. | Internal calculation based on ```spi_dotSize```, ```spi_dotSelectedSize``` and ```spi_dotSpacing``` | | spi_orientation | Visible orientation of the dots | LinearLayoutManager.HORIZONTAL | | spi_firstDotDrawable | Custom drawable of the first dot, color is tinted and size is changed like standard dots. If first dot is also the last one then this value is taken into account. | `null` | -| spi_lastDotDrawable | Custom drawable of the last dot, color is tinted and size is changed like standard dots. | `null` | +| spi_lastDotDrawable | Custom drawable of the last dot, color is tinted and size is changed like standard dots. | `null` | +| spi_selectedDotDrawable | Custom drawable of the selected dot, color is tinted and size is changed like standard dots. | `null` | ## TODO 1. Some extreme customizations may work incorrect. diff --git a/demo/src/main/res/drawable/baseline_play_arrow_24.xml b/demo/src/main/res/drawable/baseline_play_arrow_24.xml new file mode 100644 index 0000000..e3fd2e9 --- /dev/null +++ b/demo/src/main/res/drawable/baseline_play_arrow_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index 21fb6cb..f0ab6cb 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -58,7 +58,8 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@id/pager_title2" app:spi_dotColor="@color/dotNormal" - app:spi_dotSelectedColor="@color/dotHighlight" /> + app:spi_dotSelectedColor="@color/dotHighlight" + app:spi_selectedDotDrawable="@drawable/baseline_play_arrow_24"/> = Build.VERSION_CODES.LOLLIPOP) { dotDrawable.setTint(paint.getColor()); diff --git a/scrollingpagerindicator/src/main/res/values/attrs.xml b/scrollingpagerindicator/src/main/res/values/attrs.xml index 38e55cb..ebcd339 100644 --- a/scrollingpagerindicator/src/main/res/values/attrs.xml +++ b/scrollingpagerindicator/src/main/res/values/attrs.xml @@ -19,5 +19,6 @@ + From e33bbd49be5dc0f516487271a6fac2c7c543ae00 Mon Sep 17 00:00:00 2001 From: thirstycoda Date: Mon, 21 Aug 2023 15:24:40 +0100 Subject: [PATCH 2/2] Added setSelectedDotDrawable --- .../scrollingpagerindicator/ScrollingPagerIndicator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scrollingpagerindicator/src/main/java/ru/tinkoff/scrollingpagerindicator/ScrollingPagerIndicator.java b/scrollingpagerindicator/src/main/java/ru/tinkoff/scrollingpagerindicator/ScrollingPagerIndicator.java index 8c3d551..70a5e4a 100644 --- a/scrollingpagerindicator/src/main/java/ru/tinkoff/scrollingpagerindicator/ScrollingPagerIndicator.java +++ b/scrollingpagerindicator/src/main/java/ru/tinkoff/scrollingpagerindicator/ScrollingPagerIndicator.java @@ -13,6 +13,7 @@ import android.widget.LinearLayout; import androidx.annotation.ColorInt; +import androidx.annotation.DrawableRes; import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -63,7 +64,7 @@ public class ScrollingPagerIndicator extends View { private final Drawable lastDotDrawable; @Nullable - private final Drawable selectedDotDrawable; + private Drawable selectedDotDrawable; private boolean looped; @@ -164,6 +165,11 @@ public void setSelectedDotColor(@ColorInt int color) { invalidate(); } + public void setSelectedDotDrawable(Drawable drawable) { + this.selectedDotDrawable = drawable; + invalidate(); + } + /** * Maximum number of dots which will be visible at the same time. * If pager has more pages than visible_dot_count, indicator will scroll to show extra dots.