http://developer.android.com/training/displaying-bitmaps/index.html
这一课包含一些常用的处理和加载图片的技巧,这些技巧可以改善用户界面组件的响应,并且避免图片超出应用的内存限制。如果你不注意这些,图片会迅速的消耗掉你可用的内存预算,导致你的应用因为可怕的异常而奔溃:
java.lang.OutofMemoryError: bitmap size exceeds VM budget.
以下是一些Android应用中的加载图片会如此危险的原因:
Lessons
Loading Large Bitmaps Efficiently
This lesson walks you through decoding large bitmaps without exceeding the per application memory limit.
Processing Bitmaps Off the UI Thread
Bitmap processing (resizing, downloading from a remote source, etc.) should never take place on the main UI thread. This lesson walks you through processing bitmaps in a background thread usingAsyncTask and explains how to handle concurrency issues.
Caching Bitmaps
This lesson walks you through using a memory and disk bitmap cache to improve the responsiveness and fluidity of your UI when loading multiple bitmaps.
Displaying Bitmaps in Your UI
This lesson brings everything together, showing you how to load multiple bitmaps into components likeViewPager and GridView using a background thread and bitmap cache.