romandanylyk / PageIndicatorView

An page indicator for Android ViewPager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to programmatically change color (selected/unselected) of indicator

c0state opened this issue · comments

I'm looking to change the color of the indicator via some dynamic logic in my application but the following call pattern doesn't seem to work:

this.pageIndicatorView.setSelectedColor(Color.BLACK);
this.pageIndicatorView.invalidate();

If I initiate a touch event on the view pager, then the indicator picks up the event and changes the color that I set above.

Any idea what I'm missing or is this an unforeseen limitation?

I'm currently using a hack of setting the viewpager's current item to n+1 and then back to n to force the color change after the setSelectedColor() call.

It seems to be an issue with the "scale" type page indicators. From a quick call trace, the old color is being retrieved from the ScaleAnimationValue and reused in the ScaleDrawer.draw() method.

The slide page indicator type doesn't seem to have this issue. Not sure if any of the others do as well. I changed my page indicator type to slide for now to get around this.