Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create a Spalsh Screen in Android.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 82
    Comment on it

    Since we know that the "Splash Screen" just appears for the few seconds as the app get start so we need to add the time for how much second the splash screen would be shown, so to add  Splash screen in Android app follow the steps mentioned below:-

    1) Create a new Activity for Splash screen and name it as SplashActivity, below is the code for the java file of the splash screen where  I have used "Handler.postDelayed" to make the screen appear for the time according to our wish.   .

    SplashScreen.java

    public class SplashScreen extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash_screen);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
    
                    Intent intent=new Intent(SplashScreen.this,MainActivity.class);
                    startActivity(intent);
                }
            },2000);
    
        }

    2) Add Some content to your SplashScreen's xml file .

    activity_splash_screen.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
        android:layout_height="match_parent"
    
        tools:context="com.example.manjeet.fregmentactivitybawa.Java.SplashScreen">
    
     <ImageView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:background="@drawable/green"/>
    
        <TextView
            android:layout_marginTop="34dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="GO GREEN"
            android:textColor="#00ff55"
            android:textSize="30dp"
            android:layout_marginLeft="112dp"/>
    
    </RelativeLayout>
    

    3)Now to move on from one Activity to another and making Splash Screen as your parent Activity do add the SplashScreen.java  Activity in your Manifest file.

    Manifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.manjeet.fregmentactivitybawa" >
    
        <application
            android:allowBackup="true"
            android:icon="@drawable/grasses"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".Java.MainActivity"
                android:label="@string/app_name" >
                </activity>
            <activity
                android:name=".Java.SplashScreen"
                android:label="@string/title_activity_splash_screen" >
    <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>        
    </activity>
        </application>
        
    </manifest>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: