标签:c style class blog code java
在onDraw方法里,我们经常会看到调用save和restore方法,它们到底是干什么用的呢?
int px = getMeasuredWidth(); int py = getMeasuredWidth(); // Draw background canvas.drawRect(0, 0, px, py, backgroundPaint); canvas.save(); canvas.rotate(90, px/2, py/2); // Draw up arrow canvas.drawLine(px / 2, 0, 0, py / 2, linePaint); canvas.drawLine(px / 2, 0, px, py / 2, linePaint); canvas.drawLine(px / 2, 0, px / 2, py, linePaint); canvas.restore(); // Draw circle canvas.drawCircle(px - 10, py - 10, 10, linePaint);
如果我们不调用save和restore会是什么样子呢?
Canvas的save和restore,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/yuyutianxia/p/3766743.html