androidx / constraintlayout

ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way
Apache License 2.0
1.06k stars 177 forks source link

Carousel changes views randomly if used inside a RecyclerView #832

Closed lucasqrib closed 11 months ago

lucasqrib commented 11 months ago

Using the Carousel as a RecyclerView item changes the visible item randomly when it is reattached to the window. The selected item index is not affected, just the views.

carousel_bug.webm

The onAttachedToWindow method, which is called multiple times on a RecyclerView, adds all views to the array and makes it increase every time it is reattached, so I guess it needs to clear the view arrays before adding it.

I reproduced it using the latest release version: 2.1.4

Sample project: https://drive.google.com/file/d/1nw1bKkbCc4nclZTCf9Dvf1tIoaZyGmGh/view?usp=sharing

lucasqrib commented 11 months ago

It seems fixed in the newest alpha version: 2.2.0-alpha10

So I'm closing the issue.