zhpanvip / viewpagerindicator

🔥 Worked with ViewPager and ViewPager2,support multiple slider styles and multiple slide mode.This repo was split from BannerViewPager-
https://github.com/zhpanvip/BannerViewPager
Apache License 2.0
696 stars 58 forks source link

The default status of indicator is not correct #10

Closed JimLyu closed 3 years ago

JimLyu commented 3 years ago

Hello, I use the option like this: (Java)

    IndicatorOptions options = new IndicatorOptions();
    options.setIndicatorStyle(IndicatorStyle.CIRCLE);
    options.setSlideMode(IndicatorSlideMode.WORM); 
    options.setSliderColor(Color.CYAN, Color.BLUE);
    options.setSliderWidth(36, 36);
    indicator.setIndicatorOptions(options);

The color of first circle (default position is 0) would be Cyan (normalColor) until I slid it. And I found out that only I set IndicatorSlideMode.NORMAL, it would be the correct color. How should I do if I want to make the first circle in "checkedColor" in the beginning when the view shows?

Thank you

zhpanvip commented 3 years ago

Don't use IndicatorOptions to set the parameters for indicator, you just do like the Code on the REDMINE

indicatorView.setSliderColor(normalColor, checkedColor)
                    .setSliderWidth(resources.getDimension(R.dimen.dp_10))
                    .setSliderHeight(resources.getDimension(R.dimen.dp_5))
                    .setSlideMode(IndicatorSlideMode.WORM)
                    .setIndicatorStyle(IndicatorStyle.CIRCLE)
                    .setupWithViewPager(view_pager2)
JimLyu commented 3 years ago

Thanks for answer, but by this way, it still didn't show any activated circle in the beginning.

zhpanvip commented 3 years ago

It's something wrong with you code in your project? You can check it. Or you can copy the following code to your project:

val options = IndicatorOptions()
        options.indicatorStyle = IndicatorStyle.CIRCLE
        options.slideMode = IndicatorSlideMode.WORM
        options.setSliderColor(Color.CYAN, Color.BLUE)
        options.setSliderWidth(36f, 36f)
        indicatorView.setIndicatorOptions(options)
        indicatorView.setupWithViewPager(view_pager2)

I have test this code,It works well.

JimLyu commented 3 years ago

Thanks a lot! I finally succeeded while I changed the "ViewPager" to "ViewPager2" and made the adapter it required.

zhpanvip commented 3 years ago

So weird,I also test with ViewPager,It's nothing problem.

zhpanvip commented 3 years ago

Oh! I'm so sorry,I think this is a bug in version 1.0.6,and it was coincidentally fixed by recently commits,but The latest code has not been released. I will be release a new version soon.