Animated Splash Screen in Android Studio with the SplashScreen API
Add a modern animated splash screen using the official SplashScreen API, the way Android 12 and later expect it. Your app icon animates in, then the app opens without a separate splash activity.
What you'll learn
- Set up the SplashScreen API and its theme
- Animate the app icon on launch
- Keep the splash visible while data loads
- Avoid the old "splash activity" pattern
Before you start
- Android Studio (any recent version)
- Basic Java: variables, methods and if/else
- An emulator or an Android phone
How it fits together
- 1Starting theme
- 2Animated icon plays
- 3Keep on screen while loading
- 4Exit animation
- 5MainActivity
Build it step by step
1. Create the project
In Android Studio choose New Project → Empty Views Activity, with Language Java and Minimum SDK API 24.
2. Add the SplashScreen library
In app/build.gradle.kts, add inside dependencies { }:
implementation("androidx.core:core-splashscreen:1.2.0")Then press Sync Now. It brings the Android 12 splash to older versions too.
3. Draw the icon
Add your logo as a vector drawable. Keep the artwork inside the middle 72dp of the 108dp canvas, because the splash crops it into a circle. Put the shapes you want to move inside a named <group>.
4. Animate it
Create a res/animator folder and an animator that changes the group's scaleX, scaleY and rotation. Then an animated-vector drawable connects the group's name to that animator.
5. Create the Starting theme
In themes.xml, add a theme whose parent is Theme.SplashScreen, and set:
windowSplashScreenBackground: the background colourwindowSplashScreenAnimatedIcon: your animated drawablewindowSplashScreenAnimationDuration: how long the animation runspostSplashScreenTheme: your normal app theme, used after the splash
Give the application this theme in the manifest.
6. Install the splash
In MainActivity.onCreate, call SplashScreen.installSplashScreen(this) before super.onCreate().
7. Keep it up while loading
setKeepOnScreenCondition keeps the splash visible while it returns true. Set your ready flag when loading finishes. The sample waits 1.5 seconds to stand in for real work.
8. Animate it away
setOnExitAnimationListener gives you the splash view and its icon. Shrink and fade them, and call remove() when the animation ends.
9. Run it
Close the app completely and open it again from the launcher: the icon pops in, holds while "loading", then shrinks away. Android Studio's Run button sometimes skips the splash, so test from the launcher.
If something goes wrong
- No animation: the animated icon plays on Android 12 and later. Older versions show the static icon.
- Crash on launch:
installSplashScreenmust come beforesuper.onCreate(), and the manifest must use the Starting theme. - The app looks wrong after the splash: check
postSplashScreenThemepoints to your normal theme.
Files affected
Check what to add and what to replace before copying code.
- app/build.gradle.ktsAdd these lines
- app/src/main/java/com/example/animatedsplashscreen/MainActivity.javaReplace file
- app/src/main/res/layout/activity_main.xmlReplace file
- app/src/main/AndroidManifest.xmlReplace file
- app/src/main/res/animator/brackets_pop.xmlAdd these lines
- app/src/main/res/values/colors.xmlReplace file
- app/src/main/res/drawable/ic_splash_animated.xmlAdd these lines
- app/src/main/res/drawable/ic_splash_logo.xmlAdd these lines
- app/src/main/res/values/strings.xmlReplace file
- app/src/main/res/values/themes.xmlReplace file
Required setup
These are additions to an existing project—not replacement project files.
Add the SplashScreen library
Add these linesWhere: app/build.gradle.kts
Add this line inside dependencies, then Sync Now.
implementation("androidx.core:core-splashscreen:1.2.0")
Application code
Select a file to see its code and where it belongs.
This code uses package com.example.animatedsplashscreen. Change that first line to your own package, the one at the top of your MainActivity.
app/src/main/java/com/example/animatedsplashscreen/MainActivity.javaInstalls the splash, keeps it up while loading, and animates it away.
package com.example.animatedsplashscreen;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.animation.AnticipateInterpolator;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.splashscreen.SplashScreen;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
/**
* Uses the official SplashScreen API, so there is no separate splash activity.
* 1. installSplashScreen() shows the animated icon set in the theme.
* 2. setKeepOnScreenCondition() keeps it up until the app is ready.
* 3. setOnExitAnimationListener() animates it away.
*/
public class MainActivity extends AppCompatActivity {
private volatile boolean ready = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
// Must be called before super.onCreate().
SplashScreen splashScreen = SplashScreen.installSplashScreen(this);
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(bars.left, bars.top, bars.right, bars.bottom);
return insets;
});
// Keep the splash on screen while the app "loads". Replace the delay with your real loading work.
splashScreen.setKeepOnScreenCondition(() -> !ready);
new Handler(Looper.getMainLooper()).postDelayed(() -> ready = true, 1500);
// When the splash leaves, shrink the icon and fade the splash, then remove it.
splashScreen.setOnExitAnimationListener(provider -> {
View icon = provider.getIconView();
AnimatorSet exit = new AnimatorSet();
exit.playTogether(
ObjectAnimator.ofFloat(icon, View.SCALE_X, 1f, 0.4f),
ObjectAnimator.ofFloat(icon, View.SCALE_Y, 1f, 0.4f),
ObjectAnimator.ofFloat(provider.getView(), View.ALPHA, 1f, 0f));
exit.setInterpolator(new AnticipateInterpolator());
exit.setDuration(400);
exit.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
provider.remove();
}
});
exit.start();
});
}
}


