最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - Shared element transition: renderInSharedTransitionScopeOverlay().animateEnterExit() - Unresolved reference: animateEn

programmeradmin0浏览0评论

From the docs I found the following sample code:

Sometimes you might want your non-shared composable to animate away as well as remain on top of the other composables before the transition. In such cases, use renderInSharedTransitionScopeOverlay().animateEnterExit() to animate the composable out as the shared element transition runs:

JetsnackBottomBar(
    modifier = Modifier
        .renderInSharedTransitionScopeOverlay(
            zIndexInOverlay = 1f,
        )
        .animateEnterExit(
            enter = fadeIn() + slideInVertically {
                it
            },
            exit = fadeOut() + slideOutVertically {
                it
            }
        )
)

Also usage in the sample project.

But when I try it animateEnterExit is unresolved:

with(sharedTransitionScope) {
    BottomCard(
        modifier = Modifier
            .renderInSharedTransitionScopeOverlay(
                zIndexInOverlay = Float.MAX_VALUE,
            )
            .animateEnterExit(
                enter = fadeIn() + slideInVertically {
                    it
                },
                exit = fadeOut() + slideOutVertically {
                    it
                }
            ),
    )
}

composeBom = "2025.01.01"

From the docs I found the following sample code:

Sometimes you might want your non-shared composable to animate away as well as remain on top of the other composables before the transition. In such cases, use renderInSharedTransitionScopeOverlay().animateEnterExit() to animate the composable out as the shared element transition runs:

JetsnackBottomBar(
    modifier = Modifier
        .renderInSharedTransitionScopeOverlay(
            zIndexInOverlay = 1f,
        )
        .animateEnterExit(
            enter = fadeIn() + slideInVertically {
                it
            },
            exit = fadeOut() + slideOutVertically {
                it
            }
        )
)

Also usage in the sample project.

But when I try it animateEnterExit is unresolved:

with(sharedTransitionScope) {
    BottomCard(
        modifier = Modifier
            .renderInSharedTransitionScopeOverlay(
                zIndexInOverlay = Float.MAX_VALUE,
            )
            .animateEnterExit(
                enter = fadeIn() + slideInVertically {
                    it
                },
                exit = fadeOut() + slideOutVertically {
                    it
                }
            ),
    )
}

composeBom = "2025.01.01"
Share Improve this question asked Feb 5 at 19:05 user924user924 12.2k12 gold badges88 silver badges189 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Found the answer animateEnterExit is within the AnimatedVisibility scope:

https://developer.android.com/develop/ui/compose/animation/composables-modifiers#animatedvisibility-enter-exit

Update:

And not just AnimatedVisibility, also AnimatedContent

And we can use: with(animatedContentScope) { } which we get from NavHost's composable: https://developer.android.com/develop/ui/compose/animation/shared-elements/navigation

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论