SurfaceView示例代码
我需要 Android SurfaceView 的示例教程,或者使用它的示例代码(可以共享)。 API 演示对我来说很难理解。有人有替代方案吗?
I need a sample tutorial for the android SurfaceView
, or sample code using it that can be shared. The API demos are difficult for me to understand. Does anyone have alternatives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的世界地图演示的此提交 app 向您展示从 android.view.View 转换为一个 android.view.SurfaceView 和一个 android.view.SurfaceHolder.Callback。
它通过在
SurfaceView
的DrawThread
中使用View
的onDraw()
并通过从SurfaceView
的surfaceChanged
中调用View
的onSizeChanged()
。它只是使差异更小并且更容易理解。This commit of my WorldMap demo app shows you the changes necessary to convert from an android.view.View to an android.view.SurfaceView with an android.view.SurfaceHolder.Callback.
It cheats a bit by using the
View
'sonDraw()
from within theSurfaceView
'sDrawThread
and by calling theView
'sonSizeChanged()
from within theSurfaceView
'ssurfaceChanged
. It just makes the diff smaller and easier to understand.我不确定您是否需要
GLSurfaceView
,但是 glbuffer 是我最喜欢的例子之一。这是发生操作的 java 文件: GlBufferActivity
该项目还依赖于本机方法和 NDK,因此它可能不完全是您正在寻找的,但如果您想通过普通 C api 使用 OpenGL,那么它是一个很好的起点。
I'm not sure if you're needing a
GLSurfaceView
or not, but glbuffer is one of my favorite examples.This is the java file where the action happens: GlBufferActivity
The project also relies on native methods and the NDK, so it may not be exactly what you're looking for, but it's a great starting point if you want to work with OpenGL via the normal C apis.