Headertab

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday 2 June 2016

SplashScreen in android

Hello friends

   actvity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#37474f" >

    <ImageView
        android:id="@+id/imgLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/yourlogo" />

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="100dp"
        android:gravity="center_horizontal"
        android:text="http://samsetdev.blogspot.in"
        android:textColor="#ffa000"
        android:textSize="25sp" />


</RelativeLayout>

AndroidMainifeast.xml

<?xml version="1.0" encoding="utf-8"?>
    package="com.example.splash"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="21" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <!-- SplashActivity -->
        <activity
            android:name="com.example.splash.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
           >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- MainActivity -->
        <activity
            android:name="com.example.splash.MainActivity"
            android:label="@string/app_name" >
        </activity>

    </application>


SplashActvity.java

public class SplashActivity extends Activity {

   // Splash screen timer
   private static int SPLASH_TIME_OUT = 3000;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_splash);

      new Handler().postDelayed(new Runnable() {

         /*
          * Showing splash screen with a timer. This will be useful when you
          * want to show case your app logo / company
          */

         @Override
         public void run() {
            // This method will be executed once the timer is over
            // Start your app main activity
            Intent i = new Intent(SplashActivity.this, MainActivity.class);
            startActivity(i);

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

}


MainActvity.java

public class SplashActivity extends Activity {


   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

   }

}



Thank you


No comments:

Post a Comment