Skip to content

Add setter and getter for normal and selected dot size #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class ScrollingPagerIndicator extends View {
private int infiniteDotCount;

private final int dotMinimumSize;
private final int dotNormalSize;
private final int dotSelectedSize;
private int dotNormalSize;
private int dotSelectedSize;
private final int spaceBetweenDotCenters;
private int visibleDotCount;
private int visibleDotThreshold;
Expand Down Expand Up @@ -131,6 +131,43 @@ public void setDotColor(@ColorInt int color) {
invalidate();
}

/**
* @return the dot size
*/

public int getDotSize() {
return dotNormalSize;
}

/**
* Sets dot size
*
* @param size dot color
*/
public void setDotSize(int size) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this feature? Do you need dynamically change dot sizes?

Copy link
Author

@melikaafrakhteh melikaafrakhteh Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because I cannot use xml and I have to change the size of dots programmatically in code. The default size is not ok for my slider.

dotNormalSize = size;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like you need also change dotMinimumSize, like in constructor.

requestLayout();
}

/**
* @return the selected dot size
*/

public int getSelectedDotSize() {
return dotSelectedSize;
}

/**
* Sets selected dot size
*
* @param size selected dot color
*/

public void setSelectedDotSize(int size) {
dotSelectedSize = size;
requestLayout();
}

/**
* @return the selected dot color
*/
Expand Down Expand Up @@ -358,8 +395,7 @@ public void onPageScrolled(int page, float offset) {
} else if (itemCount > 1) {
scaleDotByOffset(0, 1 - offset);
}
}
else { // Vertical orientation
} else { // Vertical orientation
scaleDotByOffset(page - 1, offset);
scaleDotByOffset(page, 1 - offset);
}
Expand Down