본문 바로가기

C.E

Splash 화면 만들기


1. Activity 만든다. (SplashActivity)


1
2
3
4
5
6
7
8
9
10
11
12
13
public class SplashActivity extends Activity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
                                        //넘어갈 액티비티
        Intent intent = new Intent(this, MainActivity.class);
        intent.putExtra("state","launch");
        startActivity(intent);
        finish();
    }
}
cs

2. XML 수정한다. (styles.xml)


1
2
3
    <style name="SplashTheme" parent="android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">@drawable/splash_img</item>
    </style>
cs

3. AndroidManifest.xml 수정한다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!-- main -->
        <activity android:name=".MainActivity">
 
        </activity>
 
        <!-- splash -->
        <activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme"
            android:screenOrientation="portrait"
            android:noHistory="true"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
cs

끝.