我正在开发一款主要由TextView和Button组成的应用程序,外观并不令人兴奋。我想创建一个动态背景,其中有3D对象移动、变色等特效。如何实现呢?我知道一些简单的OpenGL,比如创建形状等操作。是否有一个视图可以添加到我的xml布局中,并将其设置为我的动画?任何帮助将不胜感激。
<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);
}