cjserio
cjserio

Reputation: 2897

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?

Upvotes: 3

Views: 3403

Answers (2)

Karl John Hernandez
Karl John Hernandez

Reputation: 328

Here is what I did to overcome this situation...

I created a custom layout named loader.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/selectLevelID"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/loader"
    android:orientation="vertical" >
</RelativeLayout>

after that, I used this while creating the renderer for glSurfaceView

    public GlRenderer(Context ctx)
            {
loader_dialog = new Dialog(context,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
loader_dialog.setContentView(R.layout.loader);
loader_dialog.show()
//do your initializations....
loader_dialog.dismiss();
}

;

or just call loader_dialog.dismiss(); after you loaded all your objects, textures etc...

Upvotes: 4

CommonsWare
CommonsWare

Reputation: 1007554

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

Upvotes: 4

Related Questions