일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 다른버전 다운로드
- 코틀린
- 앱개발
- fragment
- ColdStream
- 뷰모델팩토리
- DI
- 어댑터 효율적으로 사용하기
- list adapter
- hilt
- notifyDataSetChanged 대신 사용하기
- 계층 분리
- 화면전환
- 안드로이드 스튜디오 구버전 다운받기
- Android
- 의존성주입
- koltin
- Clean Architecture
- Kotlin
- 안드로이드
- android aac
- SQLite
- error
- compose
- 클린아키텍처
- DiffUtilCallback
- HotStream
- 안드로이드 DB
- notifyDataSetChanged 비효율
- 키보드 숨기기
Archives
- Today
- Total
DoReMi
[Kotlin] Splash Screen(스플래쉬 스크린) 본문
▶ Splash Screen 이란?
Splash Screen은 애플리케이션을 실행할 때 로고를 보여주고 지정된 시간이 지나면 사라지는 화면을 말한다.
▶ 기본 예시
App 수준의 build.gradle
implementation 'androidx.core:core-splashscreen:1.0.1'
res - values - themes.xml
<!-- Splash Screen -->
<style name="AppTheme.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/white</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/lbs_logo</item>
<item name="windowSplashScreenAnimationDuration">1000</item>
<item name="postSplashScreenTheme">@style/Theme.Mini01_LBS01</item>
</style>
windowSplashScreenBackground - 스플래시스크린 백그라운드 색상
windowSplashScreenAnimatedIcon - 스플래시 스크린 아이콘(위에 코드에서는 직접 만든 minmap을 사용함)
windowSplashScreenAnimationDuration - 스플래시 스크린 보여줄 시간 (1000ms - 1초)
postSplashScreenTheme - 스플래시 스크린에 적용할 테마 설정
MainActivity.kt
onCreate 안에
installSplashScreen()
AndroidManifest.xml
android:theme="@style/AppTheme.Splash"
▶ 스플래시 스크린 커스터마이징
MainActivity.kt
@RequiresApi(Build.VERSION_CODES.S)
override fun onCreate(savedInstanceState: Bundle?) {
...
// SplashScreen 실행
val splashScreen = installSplashScreen()
splashScreenCustomizing(splashScreen)
...
}
// SplashScreen 커스터마이징
@RequiresApi(Build.VERSION_CODES.S)
fun splashScreenCustomizing(splashScreen: androidx.core.splashscreen.SplashScreen) {
// SplashScreen이 사라질 때 동작하는 리스너를 설정한다.
splashScreen.setOnExitAnimationListener {
// 가로 비율 애니메이션
val scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f, 2f, 1f, 0f)
// 세로 비율 애니메이션
val scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 2f, 1f, 0f)
// 투명도
val alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 1f, 0.5f, 0f)
// 애니메이션 관리 객체를 생성한다.
// 첫 번째 : 애니메이션을 적용할 뷰
// 나머지는 적용한 애니메이션 종류
val objectAnimator =
ObjectAnimator.ofPropertyValuesHolder(it.iconView, scaleX, scaleY, alpha)
// 애니메이션 적용을 위한 에이징
objectAnimator.interpolator = AnticipateInterpolator()
// 애니메이션 동작 시간
objectAnimator.duration = 1000
// 애니메이션이 끝났을 때 동작할 리스너
objectAnimator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
super.onAnimationEnd(animation)
// SplashScreen을 제거한다.
it.remove()
}
})
// 애니메이션 가동
objectAnimator.start()
}
}
'Android > 개념' 카테고리의 다른 글
[Kotlin] Fragment - 프래그먼트(분기) (0) | 2023.07.25 |
---|---|
[Kotlin] Google Map(LBS - 위치기반서비스) (0) | 2023.07.20 |
[Kotlin] Android MVVM 패턴 (0) | 2023.07.14 |
[Kotlin] RecyclerView - 리사이클러뷰 (0) | 2023.07.13 |
[Kotlin] Intent - 인텐트 (0) | 2023.07.04 |