Create Android Splash Screen / Loading

I have an application that uses OpenGL in GLSurfaceView. The problem is that the initial load takes a lot of time when processing textures and getting ready for work.

What I want to do is show a simple PNG (with a little animation) while the GLSurfaceView is preparing. Once ready for rendering, I would like to tear down the splash of the screen.

What is the right way to do this? I tried ViewFlipper, ViewSwitcher and many other things to switch between my R.layout.main view and my GLSurfaceView, but I can’t figure out how it is right.

Any ideas?

+3
source share
2 answers

№1: GLSurfaceView be android:visibility="invisible" XML

# 2: GLSurfaceView FrameLayout

# 3: ImageView FrameLayout

№4: GLSurfaceView , ImageView GLSurfaceView

+4

, ...

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>

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();
}

;

loader_dialog.dismiss(); , ..

+3

Source: https://habr.com/ru/post/1729439/


All Articles