Search code examples
androidopengl-esglsurfaceview

Creating a proper Android Splash/Loading screen


I have an application that uses OpenGL on a GLSurfaceView. The problem is that the initial load takes quite a while processing textures and getting things ready.

What i want to do is have a simple PNG displayed (with a slight animation) while the GLSurfaceView is getting ready. As soon as it's ready to render, i would like to tear down the splash screen.

What is the right way to do this? I've tried ViewFlipper, ViewSwitcher and a bunch of other things to switch between my R.layout.main view and my GLSurfaceView but i can't seem to get it right.

Any ideas?


Solution

  • Step #1: Make your GLSurfaceView be android:visibility="invisible" in your layout XML

    Step #2: Put that GLSurfaceView inside of a FrameLayout

    Step #3: Add an ImageView as another child of the same FrameLayout

    Step #4: When the GLSurfaceView is ready, make the ImageView be invisible and make the GLSurfaceView be visible