I have a ListView with each item being a custom layout with multiple Views (including a large image of ~445×250, a smaller image of ~40×40, etc). While scrolling, the animation is extremely choppy.
Can someone recommend how I can improve performance?
One approach I tried was to eliminate any transparency in the images being used. This did improve it slightly, though there is still a noticeable lag when before a new item scrolls into view.
Update:
Here’s the View heirarchy for the custom layout (for each item) – http://pastie.org/3333903
Looking at the layout provided, there are a few things that may cause performance issues:
RelativeLayout/TableLayoutwhere possible instead of nestedLinearLayouts.ListView– if your rows start becoming complex, it may be a sign to look at something else to display this information.GestureOverlayViewseems a bit heavy for aListViewrow item. Is this necessary? ConsideringListViews a scrollable by touch, having custom gestures on row items may be a bit confusing.You can also try using
android:persistentDrawingCache="scrolling"and the ViewHolder pattern to squeeze out a bit more performance.If you download the latest version of ADT, it will also guide you in optimising your layouts.
Apart from layout optimisations, minimal work should be done in the
getViewmethod of yourListAdapter.Additionally, you can use
android:hardwareAccelerated="true"to take advantage of hardware in Android 3.0+.