- @Preview
- @Composable
- fun LottieAnimationSample() {
- val composition by rememberLottieComposition(
- LottieCompositionSpec.RawRes(R.raw.lottie_animation)
- )
- val lottieAnimatable = rememberLottieAnimatable()
- val coroutineScope = rememberCoroutineScope()
- Box(
- contentAlignment = Alignment.Center,
- modifier = Modifier
- .fillMaxSize()
- .pointerInput(Unit) {
- detectTapGestures(
- onTap = {
- coroutineScope.launch {
- lottieAnimatable.animate(composition)
- }
- },
- )
- }
- ) {
- LottieAnimation(
- composition = composition,
- progress = { lottieAnimatable.value },
- modifier = Modifier.size(72.dp),
- )
- }
- }
2023年3月16日木曜日
Compose の LottieAnimation でクリックしたときにアニメーションさせる
rememberLottieAnimatable を使います。
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿