android - 自定义控件时能保存onDraw中的canvas吗?
ringa_lee
ringa_lee 2017-04-18 09:06:15
0
1
573

我指的是将onDraw的参数canvas用类成员变量保存着,在onTouchEvent中直接使用这个canvas进行drawLine等等操作,有没有这种做法?

ringa_lee
ringa_lee

ringa_lee

reply all(1)
迷茫

This should just prevent it from crashing. The actual output will not get the result you want. This is because you are artificially destroying the draw mechanism of View.

If you need to redraw, when View#onTouchEvent(...), set the parameters required for draw (non-canvas), and then call View#invalidate() , notification View#onTouchEvent(...)时, 设置好draw需要的参数(非canvas), 然后再调用 View#invalidate(), 通知Viewredraw.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template