android / views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.
Apache License 2.0
5.03k stars 3.01k forks source link

ViewPager2 Sliding Lag #229

Open PJYGit opened 2 years ago

PJYGit commented 2 years ago

After migrating my ViewPager to ViewPager2 (so as the ViewHolder and Adapter), I'm facing some sliding lag problem.

I've found out that onCreateViewHolder() and onBindViewHolder() runs after the sliding motion when using ViewPager while it goes before when using ViewPager2. This may cause sliding lag problems since all these 2 functions run in the UI thread.

My ViewHolder is complex and it can't be simplified that well due to some business reason.Is it possible to delay these 2 functions in ViewPager2? Or is there any other way to solve my problem?

Appreciated!

kriztho commented 3 months ago

Has anyone from Google support looked at this? I'm still experiencing sliding lag even when I generate fragments that contain nothing but a simple background.