Reputation: 10415
When I want to scroll from first page of a ViewPager
to the latest page in ViewPager
the FragmentStateAdapter
renders all views in its way from very first to the very last one.
I mean the application should render all the fragments in its scrolling path.
This will cause huge overhead to program specifically if the content of frgaments are going to be populated by calling some sort of web service or by doing some processing activities on every page.
In my application I use tabbed buttons (implemented by a RecylerView
) to scroll to a fragment in ViewPager using smoothScroll and in some cases I'm not using smoothscroll.
positionViewPager.setCurrentItem(index, smoothScroll);
My question are there any methods that skips rendering of pages in the scrolling path?
I mean if I want to scroll from 1st page to 20th page, are there any methods to avoid rendering pages from 3rd-18th (considering I'm using caching for only one page (positionViewPager.setOffscreenPageLimit(1)
)
I should note that my view pagers is extender from androidx.viewpager2.widget.ViewPager2
Upvotes: 0
Views: 20