
How to make GIF Splash Screen In Android Studio Animated
Hiii Everyone in this Article I am sharing how to create an Awesome Splash Screen in android with GIF. We will make gif splash screen in android studio in today’s example. You can make really great animated and attractive splash screen with GIF. GIF provides seamless animation to the first impression of any android application. It is very easy to make Android Splash Screen Animation.
Following are the necessary steps to create a gif Android Splash Screen Animation.GIF Splash Screen In Android Studio
https://www.youtube.com/watch?v=evHYVCHEtyE
Step 1. Library
This project requires a third-party library to show the gif file in an XML layout file.
We will use this GitHub library: android-gif-drawable
Write below the line in the build.gradle(Module: app) file
GIF Splash Screen In Android Studio Animated
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
Now it is time to play with GIF file.
- Android has different layouts for different display factors. For example, image view for image or picture, Textview for string, Button for the clickable button, Edittext for input box, etc.
- But it has not any in a built widget for GIF. Hence, we have to create it on our own.
- This is where that Github library will help us
<pl.droidsonroids.gif.GifImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/androidgif" android:scaleType="fitXY"/>
Step 2. Create a Splash Screen Activity.
Open You Activity XML File and add these code activity_splash_screen.xml.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:background="@color/white" tools:context="rocareindia.in.caprispine.SplashActivity"> <pl.droidsonroids.gif.GifImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/splesh"/> </LinearLayout>
Step 3. After Add these codes add a GIf in your Drawable Folder. res==> drawable GIF Splash Screen In Android Studio Animated
add a gif in this folder
Step 4. After Add gif Open Your Java File Splash_Screen.java and add these code.
- This line defines the time for which you want to show the splash screen to the user.
- Here I have set it as the 8000 milliseconds which means that the splash screen will be shown for the 8 seconds.
- You can change the time interval from this line as per your requirements.
public class SplashActivity extends AppCompatActivity { private final int SPLASH_DISPLAY_LENGTH = 8000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* New Handler to start the Menu-Activity * and close this Splash-Screen after some seconds.*/ new Handler().postDelayed(new Runnable(){ @Override public void run() { /* Create an Intent that will start the Menu-Activity. */ Intent mainIntent = new Intent(SplashActivity.this,LoginActivity.class); SplashActivity.this.startActivity(mainIntent); SplashActivity.this.finish(); } }, SPLASH_DISPLAY_LENGTH); }