SurfaceView如何设置android只在需要调用时刷新屏幕?
所以我有一个专门用于我的 SurfaceView 的线程。然而,在调试过程中我发现屏幕不断重绘。我觉得这是浪费。我正在寻找一种方法来检查是否调用了 indvalidate() 或 postInvalidate() ,因此我只需要在需要时刷新屏幕。 有谁知道我到底在寻找什么或者我可以从哪里开始寻找?
So I have a thread dedicated to the my SurfaceView. However, during debugging I found that the the screen was being constantly redrawn. I feel this is waste. I'm looking for a way to check to see if indvalidate() or postInvalidate() was called so I only need to refresh the screen when it needs it.
Does anyone know what exactly I'm looking for or where I can start looking?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在为
SurfaceView 实现
。仅当 SurfaceView 可见时,这应该足以限制绘制。SurfaceHolder.Callback
时,您应该在surfaceCreated()
和surfaceDestroyed()
中启动和停止专用渲染线程You should be starting and stopping the dedicated rendering thread in
surfaceCreated()
andsurfaceDestroyed()
when implementingSurfaceHolder.Callback
for yourSurfaceView
. This should be enough to limit drawing only when theSurfaceView
is visible.