TAGS :Viewed: 6 - Published at: a few seconds ago

[ ViewPager using FragmentPagerAdapter remove invisible pages from memory ]

i am developing an application which has view pager that includes 5 different fragments. Each fragment has many views, animations and listeners so my app runs slower. When i add only first second and third pages there is no problem but after adding others performance problem starts. I thought removing invisible pages from ViewPager but it couse problem with CirclePageIndicator. i want that only 3 pages that "current page", "previous page" and "next page" will be on screen others gone.

Anyone has idea about solving performance issue?

Answer 1


try setting the OffScreenPageLimit of your ViewPager to 1: viewpager.setoffscreenpagelimit(1);