Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
279 views
Welcome To Ask or Share your Answers For Others

1 Answer

这样做应该只是不会崩溃而已吧, 实际输出会得不到你想要的结果. 因为你在人为的破坏View的draw机制.

如果需要重绘, 在View#onTouchEvent(...)时, 设置好draw需要的参数(非canvas), 然后再调用 View#invalidate(), 通知View重绘.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...