OutOfMemoryError on ViewPager

2019-07-17 04:59发布

I'm using a ViewPager with 13 pages. It is managed using a FragmentStatePagerAdapter, and each page loads 250ko images as backgrounds, and sometimes 5 images more per page.

I get extremely often an OutOfMemoryError error and I'm testing my app on a Samsung Galaxy Tab 2, so I guess I'm doing something wrong.

Is there a way to release images which are not used on the life cycles of my Fragments on the ViewPager? Any other idea?

Thanks in advance.

2条回答
不美不萌又怎样
2楼-- · 2019-07-17 05:13

Setting up the android:largeHeap to true is also extremely useful for this kind of problems.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-07-17 05:26

Everything is very well explained and detailed on Displaying Bitmaps in Your UI

查看更多
登录 后发表回答