Android ViewPager Lag

前端 未结 11 1968
迷失自我
迷失自我 2020-12-28 19:55

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 (

11条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 20:44

    For removal of lag:

    1)Put the images in res/drawable-hdpi if images are static.If it is downloaded from URL then use background thread for loading of images.

    2) set page off screen limit by this method viewPager.setOffScreenLimit(size) . With the help of that view pager cache the minimum number of screen which you set in this method by default its value is 1.

    3)You can use FragmentPagerAdapter and FragmentStatePagerAdapter for better performance.

提交回复
热议问题