简体   繁体   English

自定义视图onDraw经常被调用

[英]Custom View onDraw is constantly called

I have a custom view which I override the onDraw method to draw bitmaps using the canvas. 我有一个自定义视图,我覆盖onDraw方法使用画布绘制位图。

I can't really post any code because its quite long and complicated. 我不能真正发布任何代码,因为它很长很复杂。

I put a log in the onDraw method, and I see that it never stopped being called. 我在onDraw方法中放了一个日志,我发现它从未停止被调用。

My question is, what can trigger the onDraw method except calling invalidate on the view or its ancestors? 我的问题是,除了在视图或其祖先上调用invalidate之外,什么可以触发onDraw方法?

found the issue. 发现了这个问题。 I called getWidth() and getHeight() in the onDraw() method 我在onDraw()方法中调用了getWidth() and getHeight()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM