Slash Coding

  • Android Development
  • CSS
  • Subscribe
  • About Us
  • Contact Us
You are here: Home / Android Development / Android Splash Screen for Multiple Screens Without 9 Patch Image

Android Splash Screen for Multiple Screens Without 9 Patch Image

By Aneesh Bhatnagar

An Android Application in incomplete without a Splash Screen and when it comes to supporting multiple devices, it can be a pain to develop these images. A tried and tested way to develop images for multiple devices is to use 9 Patch Imaging. I personally found 9 Patch images pretty difficult to understand. So, I tried using different ways which could help me make a splash screen for my Android application and I ended up doing this simple thing that allowed me to make my splash screen work on various screen sizes and resolutions. This is a simple tutorial, which will enable you to make a splash screen for your Android Application without using 9 Patch images. Before you begin with the tutorial, make sure you have a project in Eclipse that you want to create a Splash Screen for. Next, you must design an image for the splash screen of your application. Here are the specifications for this image. You can make your splash screen in Photoshop, or use the free image creation Application GIMP.

  • Background: Transparent
  • Format: PNG
  • Size: 500 px X 500 px

After you have the above things, proceed with the tutorial below.

Android Splash Screen for Multiple Screen Sizes

  1. Go To New -> Android XML File and name the file “splash.xml“. Place it in the Layout Folder in your project, choose “RelativeLayout” under root element and click on Finish.
    Android XML File
  2. Now, name the file you created earlier as “splash_sc.png“. Now, Drag  and drop that image into your drawable folder. If you have drawable folders for different device sizes (like hdpi, mdpi etc.) then place the same file in all of them.
  3. Now go to the XML view on your splash.xml file and add the following code to the Relative Layout Tag in there.
    android:background="#000000"
    android:orientation="vertical"
    

    XML Code

  4. Now, Add the following code between the Relative Layout tags.
    <ImageView
    android:id="@+id/imageView1"
    android:layout_width="300dp"
    android:layout_height="300dp"
    android:layout_centerInParent="true"
    android:contentDescription="Splash Screen Logo"
    android:scaleType="fitCenter"
    android:src="@drawable/splash_sc" />
    
  5. This completes our layout part. Now let us do the coding part in Java. To do that, create  a new Java class with the following settings.
    New Java Class in Android
  6. Next, in there, delete all the Java code that is in there and add the following code.
    package com.slashcoding.helloworld;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.WindowManager;
    
    public class SplashScreen extends Activity{
    
    @SuppressWarnings("rawtypes")
    Class Aneesh;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    Thread timer = new Thread() {
    public void run() {
    try {
    sleep(3000); // 3000ms is the time to sleep
    } catch (InterruptedException e) {
    e.printStackTrace();
    } finally{
    try {
    Aneesh = Class.forName("com.slashcoding.helloworld.MainActivity");
    Intent intent = new Intent(SplashScreen.this,Aneesh);
    startActivity(intent);
    } catch (ClassNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }
    };
    timer.start();
    }
    
    @Override
    protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    finish();
    }
    
    }
    
    
  7. Save the file. Now open the AndroidManifest.xml file from your project and click on the XML view. It should look something like this.
    Android Manifest File
  8. Now, add the following code to the file inside the application tag.
    <activity
    android:name="com.slashcoding.helloworld.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>
    
  9. Now change the code shown in the below image to this.
    <activity
    android:name="com.slashcoding.helloworld.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
    <action android:name="android.intent.action.START" />
    
    <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    </activity>
    

    Code to be replaced

  10. Well, that’s all. Now just run the application and you should see the desired result!
    Splash Screen Output

I hope you enjoyed this tutorial and this tutorial helps you create a Splash Screen for your Android Application in the future. Get back to me for anything if you may have any questions. Use the comments section below or use the contact form. Also, stay subscribed to Slash Coding via RSS Feeds, or Liking our Facebook Page, or by Following us on Twitter. See you Around! 😉

Did you enjoy this article?
Subscribe to our email alerts when we post something new so you don't miss out.

About Aneesh Bhatnagar

Aneesh Bhatnagar is a freelance web developer, who specializes in front-end website development with HTML5, CSS3 and jQuery. He believes in transforming the entire web into a Responsive Web. He also specializes in use of Bootstrap framework to get websites up and running.

Search Slash Coding

Follow Us

RSS Feeds Facebook Twitter Follow Google+

Categories

  • Android Development
  • C++
  • Developer Tips
  • Slash Coding
  • Web Development
    • CSS
    • JavaScript
    • jQuery
    • PHP

Recently Published

  • Moving Ahead from Front End and Android Development
  • How to Export a Project from Android Studio
  • What is jQuery? Let’s Answer this Common Question today!
  • Mobile App Prototyping : Pixate Studio
  • How to Create a Countdown Timer using jQuery

Subscribe to Email Alerts

Eager to learn more from Slash Coding?
Sign up for daily email updates when anything new comes up. Get it straight in your inbox.

Follow Us on Social Media

RSS Feeds Facebook Twitter Follow Google+

Copyright © 2025 · Slash Coding · Powered by the Genesis Framework
Sitemap | Privacy Policy | About | Contact

×
Get Notified of the new Tutorials when they are posted!
Never miss any article update from Slash Coding. Subscribe to email alerts today!