# ComposeAnimatedSplash
**Repository Path**: ggbhack/compose-animated-splash
## Basic Information
- **Project Name**: ComposeAnimatedSplash
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-12-21
- **Last Updated**: 2023-12-21
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## 创建项目+添加依赖
```kts
// 用于实现启动图标动画的库
implementation("androidx.core:core-splashscreen:1.0.1")
```
## 使用logo图标
1. 在drawable 新增需要的图标
2. 设置锚点居中
## 创建animator 对象动画
```xml
```
## 创建animated_victor 定义一个带动画效果的矢量图
```xml
```
## 创建主题
```xml
```
## 使用主题
```xml
```
## 初始化splash
```kotlin
installSplashScreen().apply {
setKeepOnScreenCondition {
!viewModel.isReady.value
}
}
// viewModel
class MainViewModel:ViewModel() {
private val _isReady = MutableStateFlow(false)
val isReady = _isReady.asStateFlow()
init {
viewModelScope.launch {
delay(3000L)
_isReady.value = true
}
}
}
```
## 设置splash退出的动画
```kotlin
setOnExitAnimationListener { screen ->
val zoomX = ObjectAnimator.ofFloat(
screen.iconView,
View.SCALE_X,
0.4f,
0.0f
)
zoomX.interpolator = OvershootInterpolator()
zoomX.duration = 500L
zoomX.doOnEnd {
screen.remove()
}
val zoomY = ObjectAnimator.ofFloat(
screen.iconView,
View.SCALE_Y,
0.4f,
0.0f
)
zoomY.interpolator = OvershootInterpolator()
zoomY.duration = 500L
zoomY.doOnEnd {
screen.remove()
}
zoomX.start()
zoomY.start()
}
```