ViewGroup提高绘制性能
Viewgroup如果下面有很多子View。绘制的时候,需要开启其子View的绘制缓存。从而提高绘制效率。具体的代码如下
public void setChildrenDrawingCacheEnabled(boolean enabled) {final int count = getChildCount();for (int i = 0; i < count; i++) {final View view = getChildAt(i);view.setDrawingCacheEnabled(true);// Update the drawing caches view.buildDrawingCache(true);}}
void clearChildrenCache() {final int count = getChildCount();for (int i = 0; i < count; i++) {final CellLayout layout = (CellLayout) getChildAt(i);layout.setChildrenDrawnWithCacheEnabled(false);}}