Thanks a lot Romain. I feel a bit silly not realizing that sharing Drawable instances wasn't such a good idea :)
Thanks again /Henrik On Jun 1, 6:48 pm, Romain Guy <[email protected]> wrote: > > This works fine but the performance is not that great while scrolling > > since I'm inflating quite a few Views due to convertView mismatches, > > If this happens, you need to properly report the view types from your > adapter. See getItemViewType() for instance. > > > 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. > > You cannot use the SAME drawable on several views. You must have one > drawable per view. Note that having several drawables loaded from the > same resource is not bad as they share a lot of data. > > > 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. > > When you do: view1.setBackgroundDrawable(d), the drawable is linked to > view1 and gets the size of view1. Then when you do > view2.setBackgroundDrawable(d), the drawable is linked to view2 and > gets the size of view2. From now on, the drawable will invalidate > view2 and not view1. > > > Second, does this approach sound reasonable at all, or how should I go > > about to optimize this scenario? > > Just use the view types information that the adapter can provide and > let ListView do all of the work :) > > -- > Romain Guy > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

