프로젝트 [자문자답 앱] - 마무리

유의선·2023년 11월 17일
0

앱 아이콘

앱 아이콘으론 단순하게 앱 이름의 초성 문자로 만들었다.


스플래시 페이지

앱 작동 시, 잠깐 보여지는 스플래시 페이지를 만들었다.

AndroidManifest.xml

		...

        <activity
            android:name=".MainActivity"
            android:exported="false"
            android:windowSoftInputMode="adjustPan">
        </activity>
        <activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>
themes.xml

	...

    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_background</item>
    </style>
</resources>
SplashActivity.java


package org.techtown.qself;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {

    Handler handler = new Handler();


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                startActivity(intent);
            }
        }, 1000);
    }
}
splash_background.xml

...

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/splash_base"/>
    <item android:gravity="center" android:drawable="@drawable/ic_launcher_foreground"/>
</layer-list>
splash_base.xml

...

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#E7C37F"/>
</shape>

앱 아이콘과 동일한 이미지가 보이도록 하였다.

현 안드로이드 버전에서 구동 시 자동으로 앱 아이콘과 같은 스플래시 페이지를 보여주는 점, 메인 액티비티에서 BACK 버튼을 누를 시 스플래시 페이지로 넘어가는 문제가 있어 삭제하기로 했다.


0개의 댓글