我想用数字显示文本,我想实现的是在显示文本时为该文本设置动画。动画是它应该将计数器从零增加到目标值数。我尝试使用animateIntAsState但它不起作用。
这是我累的状态:
val daysCounter by animateIntAsState(
targetValue = days ,
animationSpec = tween(
durationMillis = 5000,
easing = FastOutSlowInEasing
)
)
和文字:
Text(
text = "$daysCounter",
fontSize = 40.sp,
color = MaterialTheme.colors.onPrimary,
fontWeight = FontWeight.Bold
)