[Android Apps and Games] AdvaitT17:
In this tutorial i will show you how to add simple Animated Splash Screen to your Android Application using Android Studio. You can add this Splash Screen either to existing Android Studio Project or New Android Studio Project.

Code is necessary for the implementation can be copied from here and watch the video below for the detail explanation of the implementation.

[YOUTUBE]watch?v=aLerTupCZuM[/YOUTUBE]​

If you had not installed a plugin on your computer...Visit this link:​

Click Here.​

Splashscreen.java

import android.app.Activity;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class Splashscreen extends Activity {
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
/** Called when the activity is first created. */
Thread splashTread;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splashscreen);
StartAnimations();
}
private void StartAnimations() {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
anim.reset();
LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
l.clearAnimation();
l.startAnimation(anim);

anim = AnimationUtils.loadAnimation(this, R.anim.translate);
anim.reset();
ImageView iv = (ImageView) findViewById(R.id.splash);
iv.clearAnimation();
iv.startAnimation(anim);

splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
// Splash screen pause time
while (waited < 3500) {
sleep(100);
waited += 100;
}
Intent intent = new Intent(Splashscreen.this,
MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
Splashscreen.this.finish();
} catch (InterruptedException e) {
// do nothing
} finally {
Splashscreen.this.finish();
}

}
};
splashTread.start();

}
}

layout/activity_splashscreen.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#242729"
android:layout_gravity="center"
android:id="@+id/lin_lay"
android:gravity="center"
android:orientation="vertical" >

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/splash"
android:background="@drawable/splash_img" />

</LinearLayout>

anim/alpha.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="3000" />

anim/translate.xml

<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">

<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="200%"
android:toYDelta="0%"
android:duration="2000"
android:zAdjustment="top" />

</set>

And now the last code that is for AndroidManifest.xml. Here we have to add a new activity for our java class(Splashscreen)

AndroidManifest.xml

<activity
android:name=".Splashscreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Put these code before MainActivity and change MainActivity's "android.intent.category.LAUNCHER" to "android.intent.category.DEFAULT"

Copy an image with name splash_img in png format.

So this is the simple way to add Animated Splashscreen to you Android App.

Now go to buil in top menu of Android Studio and select Generate signed Apk and epxort your Application. After Succesfull export copy it to your phone and install. Or Upload to play store.

Thanks to Karthik M

Pls hit the thanks button if i helped you:D:angel:

For more information-Visit: http://androidtechfreakat.blogspot.in

http://androidtechxdaat,weebly.com

http://advaitt17.github.io

All these codes are hosted with GitHub. You can visit there. The link is given in the source code.

XDA:DevDB Information

[GUIDE]How to add Animated Splash Screen to your Android App using Android Studio , App for all devices (see above for details)

Contributors

AdvaitT17, Karthik M

Source Code: https://github.com/AdvaitT17/How-to-add-Animated-Splash-Screen-to-you-Android-App-using-Android-Studio.-

Version Information

Status: Stable

Created 2016-04-02

Last Updated 2016-04-03