quzal

How to make GIF Splash Screen in Android Studio

Insert this into build.gradle (Module:app)

dependencies {
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.4'
}

Insert this into build.gradle (Project:)

buildscript {
    repositories {
        mavenCentral()
    }
}
allprojects {
    repositories {
        mavenCentral()
    }
}

Now go to res>layout>activty_splash_screen.xml

<pl.droidsonroids.gif.GifImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/mygif"
    />

Splash_screen.java

Place it inside onCreate method

Thread timer = new Thread(){
            public void run(){
                try{
                    sleep(5000);   // set the duration of splash screen
                }
                catch(InterruptedException e){
                    e.printStackTrace();
                } finally {
                    Intent intent = new Intent(Splash_screen.this, MainActivity.class);
                    startActivity(intent);
                }
            }
        };
        timer.start();

Place it outside the onCreate method

 @Override
    protected void onPause() {
        super.onPause();
        finish();
    }