Android fast Bitmap loading

前端 未结 4 1320
感情败类
感情败类 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:13

    Clearly, you should not leave a 2s-long operation in the UI thread.

    I suppose the ThreadPoolExecutor is a godd solution, but it is not optimal to create many threads in your pool. On background thread is sufficient. I bet you'll have better performance simply by changing this.

    I don't recommend an AsyncTask directly from the Activity, because it is fragile to config change.

    I don't recommend working with sprites. Increasing the size of one image is very dangerous on a mobile where memory is limited. In particular with sprites, you'll have to get parts of the Bitmap, hence having the full bitmap in memory for a moment.

    Now that I unanwsered your specific questions, I think you go throuh Lazy loading of images in a listview because the problem is very similar.

提交回复
热议问题