Hi,

I have a ListView containing a few different type of items, all having
their own background image and font color. In my first implementation
I implemented each type of item as its own layout with the background
image etc defined in XML (and implemented Adapter.getView() so that it
only reuses convertView if it's of the correct type).

This works fine but the performance is not that great while scrolling
since I'm inflating quite a few Views due to convertView mismatches,
so instead I tried using the same layout for all items (to benefit
fully from convertView reuse) and  changing the background image and
font size in runtime. I even keep the three background Drawables I
need as members to save time decoding them from a resource for each
item, and call View.setBackgroundDrawable() from Adapter.getView().

The problem is, sometimes the 9-patch is not correctly wrapped around
the content of the list item when using this approach. While scrolling
it usually looks correct but when the scrolling stops, or sometimes
when I just tap anywhere on the list, the background 9-patch of some
large items starts flickering and is either cropped or resized to its
original PNG size rather than stretched to wrap the content.

First of all, I suspect this is a bug? Any ideas why this happens?
Could it be that the View is not always measured to reflect the
changed content when the 9-patch is applied? I have tried adding an
extra call to View.invalidate() but it doesn't solve the problem.

Second, does this approach sound reasonable at all, or how should I go
about to optimize this scenario?

BR
/Henrik

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to