Android fast Bitmap loading

前端 未结 4 1324
感情败类
感情败类 2021-02-06 09:21

I have a block of images that I want to load on my screen. All the images are files that I downloaded and stored on SD-CARD.

So far I found two ways to do it, first is l

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-06 10:15

    One option would be to use create image cache using the WeakReference so that the image would be removed from the memory when system encounter low memory situation. This way you can keep images in memory and only need load from sdcard when they are not in memory. So your current activity would always keep the hard reference to the bitmap's required and the image cache would keep the weak reference to the bitmap's.

    Following is some more information about weak reference:

    JavaDoc weakReference

    StackOverflow post discussing using weak reference for cache

提交回复
热议问题