Android compose 三个点动画
2023-09-27 14:27:38 时间
import androidx.compose.animation.core.InfiniteRepeatableSpec
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.VectorConverter
import androidx.compose.animation.core.animateValue
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@Composable
fun ThreeDotsLoadingAnimation(color: Color = Color.Black, fontSize: TextUnit = 35.sp) {
val infiniteTransition = rememberInfiniteTransition()
val infiniteRepeatable: InfiniteRepeatableSpec<Int> = infiniteRepeatable<Int>(
animation = tween(durationMillis = 1000, easing = LinearOutSlowInEasing),
repeatMode = RepeatMode.Reverse
)
val dotCount by infiniteTransition.animateValue(
initialValue = 1,
targetValue = 4,
typeConverter = Int.VectorConverter,
animationSpec = infiniteRepeatable
)
Row(
modifier = Modifier.padding(16.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
Text(text = "dotCount ${dotCount}")
for (i in 1..dotCount) {
Text("·", fontSize = fontSize, color = color)
}
}
}
相关文章
- Android 一共有多少种动画?准确告诉你!
- Android中自定义属性的使用
- 酷炫的Android交互动画和视觉效果:高仿音悦台播放页面
- 【Android】RxJava之初始篇
- android 开源库集合的链接列表
- Android Material Design-Defining Custom Animations(自己定义动画)-(六)
- android开机动画(bootanimation)
- Android开源动画库nineoldandroids
- Android 动画之ScaleAnimation应用具体解释
- Android属性动画:动画流控制
- 在Android中实现阴影效果
- Android View的坐标获取详解以及动画坐标分析
- Android 资源报错:has no declaration in the base values folder; this can lead to crashes when the resourc
- [译] 开发者(也就是我)与Rx Observable 类的对话 [ Android RxJava2 ] ( 这到底是什么?) 第五部分
- Android 开发者如何使用函数式编程 (二)
- Android 的 Relative Layout 常量
- 【Android 启动过程】Activity 启动源码分析 ( ActivityThread 流程分析 一 )
- MAKE Android SDK
- android Animation 动画绘制逻辑