Hello I have a viewpager with several pages(using a fragment state pager), and some pngs as backgrounds to those pages. I already followed the Displaying Bitmaps in the Ui (http://developer.android.com/training/displaying-bitmaps/display-bitmap.html) so I am already caching and setting the image drawable in a background thread. But I still get some lag when swithcing pages of the pager. On Each fragment, I only inflate the view on the onCreateView() method, so I have no Idea what may be causing this lag. What can I do to remove this lag/choppy effect?
You may want to try viewPager.setOffScreenLimit(size) to the number of your pages. This will load all the fragments once and keep from reloading them while swiping.
I had similar problem.
I am showing tutorial-like pages. Each page is a full screen jpg.
At first, I put the pictures in res/drawables
folder. The viewpager is very laggy when swiping it.
Then I move those jpgs to
res/drawable-hdpi
folder, the lag is gone.
I think different optimisations are done on the pictures based on folder. So we cannot put everything in res/drawable
folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With