Android Studio - Splash Screen




1. Buka Android Studio




2. Create New Project

a. Isikan Nama Project kalian. dan Next



b. Jadi jika anda memakai Lolipop, maka os dibawah lolipop tidak akan support dengan project anda.

c. Silahkan pilih Empty Activity. dan Next.

d. Ini Next silahkan saja

e. Tampilan Building akan seperti ini

f. Tampilan Awal


3. Create New > Activity > Empty Activity (untuk activity Splash Screen nya)


4. Source Code Android Studio ( AndroidManifest.xml )

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.    package="com.example.asus.zetkaisplashscreen">
  4.     <application
  5.        android:allowBackup="true"
  6.        android:icon="@mipmap/ic_launcher"
  7.        android:label="@string/app_name"
  8.        android:roundIcon="@mipmap/ic_launcher_round"
  9.        android:supportsRtl="true"
  10.        android:theme="@style/AppTheme">
  11.         <activity android:name=".MainActivity"></activity>
  12.         <activity android:name=".splashscreen">
  13.             <intent-filter>
  14.                 <action android:name="android.intent.action.MAIN" />
  15.                 <category android:name="android.intent.category.LAUNCHER" />
  16.             </intent-filter>
  17.         </activity>
  18.     </application>
  19. </manifest>

5. Source Code Android Studio ( MainActivity.java )

  1. package com.example.asus.zetkaisplashscreen;
  2. import android.support.v7.app.AppCompatActivity;
  3. import android.os.Bundle;
  4. public class MainActivity extends AppCompatActivity {
  5.     @Override
  6.     protected void onCreate(Bundle savedInstanceState) {
  7.         super.onCreate(savedInstanceState);
  8.         setContentView(R.layout.activity_main);
  9.     }
  10. }

6. Source Code Android Studio ( splashscreen.java )

  1. package com.example.asus.zetkaisplashscreen;
  2. import android.content.Intent;
  3. import android.os.Handler;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.Window;
  7. import android.widget.TextView;
  8. public class splashscreen extends AppCompatActivity {
  9.     TextView copyright1;
  10.     @Override
  11.     protected void onCreate(Bundle savedInstanceState) {
  12.         super.onCreate(savedInstanceState);
  13.         //menghilangkan Action barr
  14.         this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  15.         setContentView(R.layout.activity_splashscreen);
  16.         copyright1 = (TextView) findViewById(R.id.copyright1);
  17.         final Handler handler = new Handler();
  18.         handler.postDelayed(new Runnable() {
  19.             @Override
  20.             public void run() {
  21.                 startActivity(new Intent(getApplicationContext(), MainActivity.class));
  22.                 finish();
  23.             }
  24.         }, 2000L); //2000 L = 2 detik
  25.     }
  26. }

7. Source Code Android Studio ( activity_main.xml )

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.constraint.ConstraintLayout 
  3.    xmlns:android="http://schemas.android.com/apk/res/android"
  4.    xmlns:app="http://schemas.android.com/apk/res-auto"
  5.    xmlns:tools="http://schemas.android.com/tools"
  6.    android:layout_width="match_parent"
  7.    android:layout_height="match_parent"
  8.    tools:context=".MainActivity">
  9.     <TextView
  10.        android:layout_width="wrap_content"
  11.        android:layout_height="wrap_content"
  12.        android:text="Hello Zetkai"
  13.        android:textSize="50dp"
  14.        app:layout_constraintBottom_toBottomOf="parent"
  15.        app:layout_constraintLeft_toLeftOf="parent"
  16.        app:layout_constraintRight_toRightOf="parent"
  17.        app:layout_constraintTop_toTopOf="parent" />
  18. </android.support.constraint.ConstraintLayout>

8. Source Code Android Studio ( activity_splashscreen )

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout
  3.    xmlns:android="http://schemas.android.com/apk/res/android"
  4.    xmlns:app="http://schemas.android.com/apk/res-auto"
  5.    xmlns:tools="http://schemas.android.com/tools"
  6.    android:layout_width="match_parent"
  7.    android:layout_height="match_parent"
  8.    tools:context=".splashscreen"
  9.    android:background="@drawable/zk">
  10.     <RelativeLayout
  11.        android:background="#50330033"
  12.        android:layout_width="match_parent"
  13.        android:layout_height="match_parent">
  14.         <ImageView
  15.            android:layout_width="366dp"
  16.            android:layout_height="218dp"
  17.            android:layout_alignParentTop="true"
  18.            android:layout_centerHorizontal="true"
  19.            android:layout_marginTop="140dp"
  20.            android:src="@drawable/zk1" />
  21.         <TextView
  22.            android:id="@+id/copyright1"
  23.            android:layout_width="match_parent"
  24.            android:layout_height="wrap_content"
  25.            android:layout_alignParentBottom="true"
  26.            android:layout_alignParentStart="true"
  27.            android:layout_marginBottom="90dp"
  28.            android:fontFamily="serif-monospace"
  29.            android:text="Powered by ©Zetkai"
  30.            android:textAlignment="center"
  31.            android:textColor="#000000"
  32.            android:textStyle="italic"
  33.            android:textSize="20dp"/>
  34.     </RelativeLayout>
  35. </RelativeLayout>


9. Untuk Source Code lengkapnya bisa di unduh di sini http://ouo.io/7YfOaV0

10. Demo Aplikasi




Komentar