android 12 (api 33) 부터 기본으로 제공되는 Splash screen api 를 이용하여 움직이는 효과가 적용된 Splash screen 을 만들어 보자.
Icon 을 기본적으로 디자인 할때는 SVG (Scalable Vector Graphics) 을 기본으로 디잔인 한다.
288 크기의 정사각형이다.192 크기를 가진다.192에 맞춰서 안쪽 사각형의 내부에 채워지는 원형이다.여러가지 그리기 도구가 있지만 이글에서 Figma 를 이용하여 Icon 을 디자인 하도록 하였다.
288 x 288 크기의 프래임을 만든다.Rectangle) 을 이용하여 사각형을 그린다. x와y는 48,48 이고 크기는 192x192 로 설정한다.사이트 마다 결과물이 다르게 나오니 편한데로 사용해서 SVG 파일을 Pigma 의 원내에 넣으면 된다.
shapeshifter.design 사이트에서 에니메이션을 제작할 수 있다.
// build.gradle.kts
// splash scree
implementation(libs.androidx.core.splashscreen)
# libs.versions.toml
[versions]
agp = "8.3.2"
coreSplashscreen = "1.1.0-rc01"
[libraries]
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreen" }
<!-- res/value/splash.xml -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.AnimatedSplash.AppSplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/white</item>
<item name="postSplashScreenTheme">@style/Theme.Lunacal</item>
</style>
</resources>
<item name="windowSplashScreenAnimatedIcon">@drawable/avd_anim</item><item name="windowSplashScreenAnimationDuration">1000</item>
<!-- res/value/splash.xml -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.AnimatedSplash.AppSplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/white</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/avd_anim</item>
<item name="windowSplashScreenAnimationDuration">1000</item>
<item name="postSplashScreenTheme">@style/Theme.Lunacal</item>
</style>
</resources>
android:theme="@style/Theme.AnimatedSplash.AppSplash">를 설정함<!-- app/manifests/AndroidManifests.xml -->
<activity
android:name=".ui.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.AnimatedSplash.AppSplash">
// MainActivity.kt
// onCreate()
val splashScreen = installSplashScreen()
splashScreen.setKeepOnScreenCondition { vm.isLoading.value }
// vm