Friday, 6 September 2013

Android ListView and items of dynamic height

Android ListView and items of dynamic height

I have a requirement to display items in a ListView, these items each have
a different height which is available within the adapter data. I have
followed all best practices to assure high performance. The problem is
when I set the height, what I do is use one view type in my adapter and
when OnCreateView is called I change it's height to prepare it before the
image is ready (I'm using Picasso for image processing so the bitmap can
come from memory cache, disk cache or directly from the network and might
take different times to load each time).
For example (inside OnCreateView):
ViewGroup.LayoutParams lp = iv.getLayoutParams();
lp.height = size[1];
// ... load image ...
This is causing some "jang" when scrolling down the ListView. Is there a
better way to achieve this within the constraints of this requirement ?
Thanks.

No comments:

Post a Comment