Android绘制路径 [英] Android draw path

查看:151
本文介绍了Android绘制路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次调用Draw方法时构造路径对象并不是一个好主意. 每次都保留路径对象并清除/设置点更好吗?

It is not good idea to construct path object every time when call Draw method. Is it better to keep path object and clear/set points every time?

更新: 另一个问题-重置"和后退"路径对象之间有什么区别?

Update: One more question - what is difference between 'reset' and 'rewind' path object?

推荐答案

是的,最好重置路径并设置点,而不是实例化新路径.这样可以防止过多的内存分配,从而导致频繁的垃圾回收. GC运行时,图形可能会暂停一会儿,尤其是在较旧的设备上,因此您希望将其保持在最低水平.

Yes, it is better to reset the path and set the points rather than instatiating a new one. This prevents excessive allocation of memory, which can lead to frequent garbage collection. When the GC runs the graphics may pause for a moment, especially on older devices so you want to keep this to a minimum.

reset()rewind()方法的效果几乎相同,除了rewind()

The reset() and rewind() methods both have pretty much the same effect, except that rewind() keeps the internal data structure intact, which can improve performance particularly if your path always has the same number of points.

这篇关于Android绘制路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆