Compose 中的 5 个简短动画
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
这 5 个简单易用的动画可帮助您在短短几分钟内让应用生动起来。即使您没有时间了解有关动画的所有知识,也能让您的 Compose 应用脱颖而出。
要点
资源
包含本指南的集合
本指南属于以下精选快速入门集合,这些集合涵盖了更广泛的 Android 开发目标:
显示图片
了解如何使用明亮动人的视觉元素为 Android 应用打造美观的外观和风格。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-06。
[null,null,["最后更新时间 (UTC):2025-02-06。"],[],[],null,["# Five quick animations in Compose\n\n\u003cbr /\u003e\n\nThese 5 quick and easy animations can help make your app come to life in just a\nfew minutes. Make your Compose app stand out even if you don't have the time to\nlearn everything there is to know about animations. \n\nKey points\n----------\n\n- Wrap changing visible states in an [`AnimatedVisibility`](/reference/kotlin/androidx/compose/animation/package-summary#(androidx.compose.animation.core.Transition).AnimatedVisibility(kotlin.Function1,androidx.compose.ui.Modifier,androidx.compose.animation.EnterTransition,androidx.compose.animation.ExitTransition,kotlin.Function1)) composable to transform how state changes show on screen.\n- To smoothly transition between two states, use the built-in modifier [`animateContentSize`](/reference/kotlin/androidx/compose/animation/package-summary#(androidx.compose.ui.Modifier).animateContentSize(androidx.compose.animation.core.FiniteAnimationSpec,kotlin.Function2)).\n- Wrap a `when` conditional in an [`AnimatedContent`](/reference/kotlin/androidx/compose/animation/package-summary#AnimatedContent(kotlin.Any,androidx.compose.ui.Modifier,kotlin.Function1,androidx.compose.ui.Alignment,kotlin.String,kotlin.Function1,kotlin.Function2)) composable to switch content based on the provided target states.\n- Use [`animate*AsState`](/reference/kotlin/androidx/compose/animation/core/package-summary#animateDpAsState(androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationSpec,kotlin.String,kotlin.Function1)) functions to perform the animation when the state of your input variable changes.\n- Compose triggers a redraw as variables change over time, creating an animation on screen.\n\nResources\n---------\n\n- [Blog: Customizing AnimatedContent in Jetpack Compose](https://medium.com/androiddevelopers/customizing-animatedcontent-in-jetpack-compose-629c67b45894)\n\nCollections that contain this guide\n-----------------------------------\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\n### Display images\n\nDiscover techniques for using bright, engaging visuals to give your Android app a beautiful look and feel. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-images) \n\nHave questions or feedback\n--------------------------\n\nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]