tommybuonomo / dotsindicator

Three material Dots Indicators for view pagers in Android !
Apache License 2.0
3.48k stars 354 forks source link

Dots not animating for ViewPager in a RecyclerView #96

Closed adeshfafriya closed 2 years ago

adeshfafriya commented 4 years ago

Hey, I have a viewpager inside a Recyclerview and I'm using DotsIndicator, when the viewpager and dots are inflated for the first time, everything works fine, but when we scroll down a bit and come back up as the views get recycled, the indicator dots stop changing the width and stays fixed in width they were before scrolling down even if we change pages.

let's say we have three items index 0, 1, 2 and before scrolling down index 1 was selected and had an elongated dot. then when the views are recycled as we come back to top, we see that the dot on index 1 is still elongated even if index 0 is selected (although selected color logic works fine, index 0 has selected bg color and index 1 has dots color, yet 1 is elongated)

And from now onwards, as we change the pages, the background color keeps updating but dots stop changing width, that is, index 1 forever stays elongated and other indices forever stay as dots irrespective of which page is selected, only bg color is updated. please let me know if there's a solution to this problem.

EvGem7 commented 4 years ago

You can try the hack:

// inside onBind()
pagerIndicator.post {
    pagerIndicator.requestLayout()
}
tommybuonomo commented 3 years ago

Hello @adeshfafriya did you tried the solution of @EvGem7. Did it worked ?

Abhishek-eezy commented 3 years ago

This hack works , thanks

tommybuonomo commented 2 years ago

Hello, thanks for your contribution ! This issue is now fixed in the new version 4.3 Thanks 🔥