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 compose 三个点动画
猜你喜欢
转载自blog.csdn.net/mp624183768/article/details/130411046
今日推荐
周排行