1. Langkah pertama anda harus membuat file XML yang nantinya berisi tampilan splashscreen Anda.
- pada values/colors.xml tambahan color name berikut :
1 | <color name="warnasplash">#f04e42</color>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 | <?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="@color/warnasplash"
android:padding="10dp"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:src="@drawable/visitor" />
<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Aplikasi Android Anda"
android:textColor="#fff" />
</LinearLayout>
</RelativeLayout>
2. Setelah itu anda harus menambahkan/membuat activity baru, sebut saja Splash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | package com.namaaplikasi.Splash;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
public class Splash extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
3. Setelah Anda membuat XML dan activity nya, Anda harus menambahkan activity tersebut di Manifest project Android Anda
1
2
3
4
5
6
7
8
9
10 | <activity android:name=".Splash" android:theme="@style/temasplash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
Selamat Mencoba. Pada tutorial selanjutnya kita akan menambahkan welcome screen / intro pada aplikasi android Anda
Wassalam.