user6075877
user6075877

Reputation: 167

How to create Animated Splash Screen such this

Example

I need to make such animated splash screen. Can you help me?

Upvotes: 1

Views: 5890

Answers (3)

Cameron Stobie
Cameron Stobie

Reputation: 59

To use a gif for your splash screen. In your build.gradle file:

compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'

In your activities layout:

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

And finally in your class file:

private static int SPLASH_TIME_OUT = 1500;
private boolean isInFront;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_gif);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            // This method will be executed once the timer is over

            if(isInFront)
            {
                // Start your app main activity
                Intent i = new Intent(SplashScreen_Gif.this, MainMenuActivity.class);
                startActivity(i);
            }

            // close this activity
            finish();
        }
    }, SPLASH_TIME_OUT);
}

Upvotes: 3

Sreehari
Sreehari

Reputation: 5655

One way is to use Tween Animation like the following. In your case needs more than one anim file

Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.myanimation);

Say like if you have to animate white circle image then do the following

ImageView image = (ImageView)findViewById(R.id.imageView);
      Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
      image.startAnimation(animation1);

Now you need to create anim file in res/anim/move.xml

<?xml version="1.0" encoding="utf-8"?>
<set
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:interpolator="@android:anim/linear_interpolator"
   android:fillAfter="true">

   <translate
      android:fromXDelta="0%p"
      android:toXDelta="75%p"
      android:duration="800" />
</set>

This is an example. You need to find ways to modify these basic animations for your requirement . For more refer this link

Upvotes: 5

Smit Davda
Smit Davda

Reputation: 638

You can use a gif image like this and use it on your splash screen instead of a normal jpg or png image

Upvotes: -1

Related Questions