Reputation: 10410
I have a linechart, what I would like to achieve not to redraw the grid each time. I tried the following, but the grid only visible in the first time, it seams that the saveLayer not working, or I just making it in the wrong way.
protected void onDraw(Canvas canvas) {
if (mRedrawGrid) {
drawGrid(canvas);
mGridLayer = canvas.saveLayer(0, 0, getWidth(), getHeight(), mPaint, Canvas.MATRIX_SAVE_FLAG);
} else
canvas.restoreToCount(mGridLayer);
drawLineChart(canvas);
}
Upvotes: 0
Views: 60
Reputation: 3215
May this help you:
Buddy take your Canvas
on a LinearLayout
and then save the whole LinearLayout's
background into a bitmap like:
ll.buildDrawingCache();
Bitmap bt = ll.getDrawingCache();
Upvotes: 1