我正在开发一个主要是 TextView 和按钮的应用程序,看起来没什么特别令人兴奋的。我想创建一个带有 3D 对象移动、改变颜色等的动画背景。实现这个的好方法是什么?我知道一些简单的 opengl,比如创建形状和做所有这些。有没有我可以添加到我的 xml 布局并将其设置为我的动画的 View ?任何帮助将不胜感激。
最佳答案
Here是android和opengl-es的指南。基本上你有
<android.opengl.GLSurfaceView
android:id="@+id/graphics_glsurfaceview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</android.opengl.GLSurfaceView>
然后在你的 onCreate 中,你给它一个 Renderer 的实现。 :
public class GraphicsRenderer implements Renderer {
// implement Renderer. This is where all the openGL stuff goes
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GLSurfaceView mGLView = (GLSurfaceView) findViewById(R.id.graphics_glsurfaceview1);
mGLView.setEGLConfigChooser(true);
mGLView.setRenderer(graphicsRenderer);
}
关于Android - 使用 opengl 为应用程序创建动画背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8176560/