简体   繁体   中英

Why are my images in the layout load slower than texts in Android?

I mean, that the TextViews loads almost at once, however the ImageViews loads a bit slower, and this looks very ugly, and disturbing.

What can I do against it?

I load the images of the ImageView on the fly, and set the images of the ImageViews with setImageBitmap() in a background process.

setImageBitmap is time-consuming - it requires loading bitmap data from storage, memory allocation, decoding, etc, etc. A TextView obviously needs to do no such thing.

You can improve the situation somewhat by using placeholder images of the same size as the image that you're about to load, using transition animations, or (whenever possible) using resource drawables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM