问题描述
您好,我有一个带有多个页面的视图分页器(使用片段状态分页器),以及一些 png 作为这些页面的背景.我已经按照 Ui 中的显示位图 (http://developer.android.com/training/display-bitmaps/display-bitmap.html) 所以我已经在后台线程中缓存和设置可绘制的图像.但是在切换寻呼机页面时我仍然会遇到一些滞后.在每个片段上,我只对 onCreateView() 方法的视图进行膨胀,所以我不知道是什么导致了这种滞后.我可以做些什么来消除这种滞后/断断续续的影响?
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?
推荐答案
我也遇到了类似的问题.
I had similar problem.
我正在显示类似教程的页面.每页都是全屏jpg.
I am showing tutorial-like pages. Each page is a full screen jpg.
一开始,我把图片放在res/drawables
文件夹中.浏览器在滑动时非常滞后.
At first, I put the pictures in res/drawables
folder. The viewpager is very laggy when swiping it.
然后我将这些 jpg 文件移动到 res/drawable-hdpi
文件夹,延迟消失了.
Then I move those jpgs to
res/drawable-hdpi
folder, the lag is gone.
我认为根据文件夹对图片进行了不同的优化.所以我们不能把所有东西都放在 res/drawable
文件夹中
I think different optimisations are done on the pictures based on folder. So we cannot put everything in res/drawable
folder
这篇关于Android ViewPager 滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!