From 01c90c664ea2b561e621f5dd06e0109147f5284c Mon Sep 17 00:00:00 2001 From: Juliane Lehmann Date: Tue, 10 Jan 2023 13:58:56 +0100 Subject: [PATCH] Allow programmatic setting of firstDotDrawable/lastDotDrawable --- changelog.md | 3 +++ .../ScrollingPagerIndicator.java | 22 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index e82096c..e26bafb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## 1.2.5 +- Add support for setting custom first and last page indicators programmatically + ## 1.2.4 - Add support for custom first and last page indicators diff --git a/scrollingpagerindicator/src/main/java/ru/tinkoff/scrollingpagerindicator/ScrollingPagerIndicator.java b/scrollingpagerindicator/src/main/java/ru/tinkoff/scrollingpagerindicator/ScrollingPagerIndicator.java index 226f18e..7feb3b2 100644 --- a/scrollingpagerindicator/src/main/java/ru/tinkoff/scrollingpagerindicator/ScrollingPagerIndicator.java +++ b/scrollingpagerindicator/src/main/java/ru/tinkoff/scrollingpagerindicator/ScrollingPagerIndicator.java @@ -57,10 +57,10 @@ public class ScrollingPagerIndicator extends View { private int selectedDotColor; @Nullable - private final Drawable firstDotDrawable; + private Drawable firstDotDrawable; @Nullable - private final Drawable lastDotDrawable; + private Drawable lastDotDrawable; private boolean looped; @@ -241,6 +241,24 @@ public void setOrientation(@Orientation int orientation) { } } + /** + * Set custom Drawable for first dot (null for default circle) + * @param drawable + */ + public void setFirstDotDrawable(@Nullable Drawable drawable) { + firstDotDrawable = drawable; + invalidate(); + } + + /** + * Set custom Drawable for last dot (null for default circle) + * @param drawable + */ + public void setLastDotDrawable(@Nullable Drawable drawable) { + lastDotDrawable = drawable; + invalidate(); + } + /** * Attaches indicator to ViewPager *