在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会是什么样子呢?

最新文章

  1. 如何保存联系人到系统通讯录(android)
  2. 在Xcode6.4中使用OpenCV
  3. DLL搜索路径和DLL劫持
  4. SimpleHttpServer的学习之UML
  5. [转] Spring - Java Based Configuration
  6. (转)Spring读书笔记-----Spring的Bean之Bean的基本概念
  7. How Many Tables--hdu1213(并查集)
  8. SVG如何做圆形图片
  9. effective c++ 思维导图
  10. 2017-2018-1 20155306 mypwd的实现
  11. 简单poi创建execl
  12. 图解HTTPS建立过程
  13. 使用jar包格式化Docker 容器日志
  14. 金蝶K3 WISE BOM多级展开_BOM成本表
  15. C#中添加对象到ArrayList的代码
  16. IMU(LPMS-B2) ROS下使用教程
  17. 洗礼灵魂,修炼python(79)--全栈项目实战篇(7)—— 多级目录菜单之地址管理系统升级版
  18. spring 循环依赖问题
  19. mongo学习使用记录1
  20. vue-cli 上手

热门文章

  1. 架设HmailServer邮件服务器以及webmail
  2. 1.2.3 Task and Back Stack - 任务和回退堆
  3. I帧、B帧、P帧、NALU类型
  4. [转]JVM内存溢出的几种方式比较
  5. vs 常用工具
  6. 11个免费的Web安全测试工具
  7. HTML基本元素的运用
  8. Firefox模拟手机访问手机网站
  9. page coloring小结
  10. 修改Chem 3D模型的化学键属性的方法有哪些