[英]Use LottieAnimation in Jetpack Compose for Icon
有沒有什么方法可以在 Jetpack Compose 中使用 LottieAnimation 將 JSON animation 文件用於交互式元素,例如待辦事項列表的復選標記,以便在單擊時設置動畫?
我目前有一個帶有圖標的行和一個進一步包含標題和副標題的列。 我希望這個圖標有一個 Lottie Animation。
您可以使用LottieAnimation
可組合項。
就像是:
var isPlaying by remember { mutableStateOf(false) }
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.heart))
val progress by animateLottieCompositionAsState(
composition,
isPlaying = isPlaying,
)
Row(verticalAlignment = Alignment.CenterVertically) {
LottieAnimation(
composition = composition,
progress = { progress },
modifier = Modifier.clickable{ isPlaying = !isPlaying }
)
Text("Title", )
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.