从 UI 线程运行 SurfaceView [英] Run SurfaceView off UI Thread
问题描述
我的 surfraceview 是我的大部分应用程序所在的地方,我想减少它的延迟,因此我被告知将它从 UI 线程中删除.是否可以在 AsyncTask 中运行 SurfaceView?
My surfraceview is where the majority of my application is and I would like to reduce its lag, thus I have been told to take it off the UI Thread. Is it possible to run a SurfaceView in an AsyncTask?
推荐答案
虽然可以从 AsyncTask 绘制到 SurfaceView,但不推荐这样做.AsyncTasks 可以在串行队列中运行,因此您可能会阻止其他任务.而只是使用一个线程.SDK 包含一个名为 LunarLander 的示例应用,它展示了如何执行此操作.
While it is possible to draw into a SurfaceView from an AsyncTask it is not recommended. AsyncTasks can run in a serial queue so you would likely block other tasks. Instead just use a Thread. The SDK contains a sample app called LunarLander which shows how to do this.
这篇关于从 UI 线程运行 SurfaceView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!