I am using ViewPager2 version 1.0.0-beta05, with a RecyclerView.Adapter, and ZoomOutPageTransformer, I found that when we call notifyDataSetChanged, the ViewPager view blow up.
In Version 1.0.0-alpha01, they said that notifyDataSetChanged fully functional (VP1 bugs addressed)
pagerAdapter?.clickListener = this
with(pager) {
clipToPadding = false
clipChildren = false
offscreenPageLimit = 3
}
pager.adapter = pagerAdapter
pager.setPageTransformer(ZoomOutPageTransformer())
GlobalScope.launch(Dispatchers.Main) {
// launch a new coroutine in background and continue
repeat(15) {
delay(5000L) // non-blocking delay for 1 second (default time unit is ms)
Log.e("hello", "notify")
pagerAdapter?.notifyDataSetChanged()
}
}
I didn't change the datasource, I just made this small test and the problem still persist, the view get been resized ugly randomly after each call of notifyDataSetChanged.
You should to read the api doc:
To fix it try to reset Page Transformer: