Friday, December 1, 2017

How to make Gif Splash screen for android




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_scree.java
Place it in the 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();
    }

Subscribe to get more videos :