Android: an easy splash screen implementation using ImageView

I’ve seen a number of suggestions of how to implement a splash screen properly. Most typical implementation is through activities. To show it, you need to make it the first activity in your application, which has a few disadvantages:

  • It is an activity, so it will use the Android-specific effect (typically sliding) to switch from splash screen to main menu, giving you little to no control over how you want your splash screen to disappear;
  • If you have an option to disable splash screen, the first activity would still show (since it is in manifest), and you’d have to close it and switch to main activity, which will have undesirable UI effects.

A much better way is to implement it as a view inside the same main activity. This would avoid both issues above.

A possible implementation is following:

   public void onCreate(Bundle savedInstanceState)

        && (savedInstanceState == null 
             || !savedInstanceState.containsKey( "splashShown" ) ) )
            // Show splash screen using the image view
            ImageView splashScreen = new ImageView(this);

            // Load the splash screen bitmap into the view - keep it light!
                                      R.drawable.splash_screen_bitmap) );

            // and set it as main view
            setContentView( splashScreen );

            // This handler would close the splash screen once the time is
            // out, and will show the main UI instead.
            new Handler().postDelayed(new Runnable() {
                public void run() {
            }, 5000); // timeout, in this case 5 seconds
            showMainUI(); // splash screen is disabled or has been shown

    protected void onSaveInstanceState(@NonNull Bundle outState)
        // Remember that we have shown the splash screen already
        outState.putBoolean( "splashShown", true );

    private void showMainUI()
        // Show the main UI - this erases the old UI, 
        // including the splashscreen
This entry was posted in android.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.