Android Splash Screen 설정 방법 (Android 12 대응)

✨ 개요

앱을 실행했을 때 처음 사용자가 마주하는 화면, Splash Screen은 UX의 첫인상을 좌우합니다.
특히 Android 12(API 31)부터는 Splash Screen이 시스템 기본 구성 요소로 통합되면서 기존 방식과 달라졌습니다.

이번 글에서는 기존 버전과 Android 12 이상에서의 Splash Screen 설정 방법, 커스터마이징 팁, 주의사항까지 실무에 필요한 내용을 정리합니다.


1. ✅ Android 12 이상: 시스템 기본 SplashScreen 활용

Android 12부터는 androidx.core.splashscreen.SplashScreen API가 도입되어 시스템이 앱 시작 시 자동으로 Splash 화면을 표시합니다.

1.1 의존성 추가 (Jetpack SplashScreen)

dependencies {
    implementation("androidx.core:core-splashscreen:1.0.1")
}

2. ✅ 구현 예제

2.1 테마에 SplashScreen 정의

<!-- res/values/themes.xml -->
<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Base.Theme.Sample" parent="Theme.Material3.DayNight.NoActionBar">
        <!-- Customize your light theme here. -->
        <!-- <item name="colorPrimary">@color/my_light_primary</item> -->
    </style>

    <style name="Theme.Sample" parent="Base.Theme.Sample" />

    <style name="Theme.MyApp.Splash" parent="Theme.SplashScreen">
        <!-- 배경 색상 -->
        <item name="windowSplashScreenBackground">@color/white</item>
        <!-- 앱 로고 -->
        <item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
        <!-- 아이콘 크기 -->
        <item name="windowSplashScreenIconBackgroundColor">@color/white</item>
        <!-- 유지 시간 최소화 (시스템 자동 제어) -->
        <item name="postSplashScreenTheme">@style/Theme.Sample</item>
    </style>

</resources>

2.2 AndroidManifest에 Splash 테마 적용

<application
        android:theme="@style/Theme.MyApp.Splash"
>

2.3 MainActivity에서 Splash 화면 유지 시간 제어 (선택)

private var isLoadingDone = false
private var isMinimumDelayPassed = false

override fun onCreate(savedInstanceState: Bundle?) {
    // SplashScreen 설치
    // 스플래시 화면 초기화
    val splashScreen = installSplashScreen()

    // 최소 2초 경과 시간 설정
    val startTime = SystemClock.elapsedRealtime()
    Handler(Looper.getMainLooper()).postDelayed({
        isMinimumDelayPassed = true
    }, 2000)

    // 예: 실제 로딩 작업이 끝났을 때
    //loadInitialData {
    isLoadingDone = true
    //}

    // 조건: 최소 시간 + 로딩 완료
    splashScreen.setKeepOnScreenCondition {
        !(isMinimumDelayPassed && isLoadingDone)
    }

    super.onCreate(savedInstanceState)
    binding = ActivityMainBinding.inflate(layoutInflater)
    setContentView(binding.root)

}

3.🎨 커스터마이징 팁

항목 적용 방법 위치
로고 애니메이션 windowSplashScreenAnimatedIcon 활용 themes.xml
배경 색 windowSplashScreenBackground themes.xml
아이콘 배경 색 windowSplashScreenIconBackgroundColor themes.xml
테마 전환 타이밍 postSplashScreenTheme 지정 themes.xml
유지 조건 제어 setKeepOnScreenCondition() 코드 (MainActivity)

4.🧠 주의사항 및 실무 팁



Related Posts