Reputation: 19290
I have a ListView that uses a custom ArrayAdapter to inflate views. Some of these Views need to display images. In order to keep the ListView from hiccuping while I scroll, I have each View that needs to load a bitmap do so on a dedicated thread, and only call back into the UI thread when the Bitmap is ready to be added to an ImageView.
This works great, but the problem is that the layout that the bitmap is added to will then need to expand to hold the Bitmap, and that instantaneous expansion looks jarring to the user.
If there was a way to load the Bitmap a little earlier, before it's scrolled into view, there will be a good chance it will be loaded by the time it is scrolled into view. So the question is:
Is there a way to extend the boundaries of the region the ListView uses to determine when to ask the Adapter for another View to display? I assume I can go hack the ListView source, but wanted to avoid that if possible.
Or, if you have a better suggestion, please let me know.
Upvotes: 0
Views: 335
Reputation: 9035
Use injustDecodeBounds to load the size of your image first in the ui thread it self and set the size of the image view accordingly then start loading full image in thread
Upvotes: 1