Skip to main content

How to add Animated Splash Screen to you Android App using Android Studio

  

In this tutorial i show you how to add 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 necessary for the implementation can be copied from here and watch the video below for the detail explanation of the implementation.



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();
}
}
view rawSplashscreen.java hosted with ❤ by GitHub

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" />
view rawalpha.xml hosted with ❤ by GitHub

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>
view rawtranslate.xml hosted with ❤ by GitHub

Copy an image with name splash_img in png format.


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

Comments

Popular posts from this blog

5 Best Courier Services in Nigeria 2019: Top Postal Companies

I could remember back in the days when we sent our mails and parcels through postal offices. But today things have changed and many of us might be wondering if Nigeria still has reliable courier services. The good news here is, Nigeria still does and more are emerging. But due to the exit of The Nigerian Postal Services (NIPOST), lots of personal and corporate enterprise in Nigeria had to search for other means to still have their packages sent as well as ensuring that their sent items are been received by the designated person or receiver. Obviously, when such opportunities present themselves, a whole bunch of individuals and investors have to start looking in the direction of providing a solution to the eminent need and that's what has happened in this sector. We have, as a result, seen new courier services emerging in Nigeria in order to provide the service of helping individuals post their items to others within and outside Nigeria. Most of the successfully establishe

post free classied in nigeria - Find Great Deals & Meet Sellers Near You.

via IFTTT

[Album download] Davido – A Good Time

Afro-pop music star  Davido  finally unlocked his sophomore album titled  “A Good Time” , following his rise to the to top of the music chain after his debut  “Genesis”  which was released 7 years ago. The long-awaited L.P features guest appearances  Dremo, Chris Brown, Summer Walker, Peruzzi, Wurld, Naira Marley, Zlatan, Poopcan, A Boogie Wit Da Hoodie, Gunna  and  Yonda.  Speaking on “A Good Time”, Davido said: It’s been 7 years since I last dropped a complete body of work. A LONG TIME. Since my first album you’ve been with me and watched me develop, grow. Progress, regress, and progress again. A TURBULENT TIME. Since then I’ve lost too many loved ones. HARD TIMES. But I have also gained 3 beautiful littles ones. A BLESSED TIME. To crown it, I found the love of my life. A BLISSFUL TIME. I’m grateful for all of this. I’m grateful to have been through this journey with all your support. And I’m grateful to be able to share this project which signifies the point of my life I