1、Android app性能优化之List篇,黄坤/玄觉,大图模式,小图模式,典型较复杂ListView,界面分析,view数量多同时显示的ListItem项比较多布局复杂,多重view嵌套数据下载,图片下载与显示(大图显示)滚动中刷新UI(倒计时),大图模式,小图模式,典型较复杂ListView,滚动过程分析,初始化时,inflate ListItems滚动中,不断调用Adapter的getView()绑定数据measure-layout-cpu draw ListItem for the first timegpu draw ListItem,Official tips,Improving
2、Layout Performance,Making ListView Scrolling Smooth,Optimizing Layout Hierarchies,Use a Background Thread,Optimizing Hold View Objects in a View Holder,Processing Bitmaps Off the UI Thread,初步优化,Avoid UI update when scrolling 避免倒计时更新/图片显示 Use a Background Thread 使用后台线程下载数据/图片Optimizing Hold View Obje
3、cts in a View Holder ViewHolderOptimizing Layout Hierarchies RelativeLayout vs LinearLayout?,深度优化,优化measure + layout效率(HierarchyViewer) 2层布局嵌套以上避免使用RelativeLayout 小图一个ListItem的measure时间,2.5ms0.7ms优化draw时间,避免image scale 滚动中不刷新图片,使用颜色占位,正确imagesize 大图listItem采取背景颜色代替图片,draw时间,7ms-2.5ms减少后台线程cpu资源占用(TraceView) 降低后台线程优先级,滚动中pause,根据cpu核心优化ThreadPoolSize 暂停后台线程时机 :onTouch代替onScrollStateChanged延迟加载图片策略,滚动停止/低速滚动 fancy,Thanks!,