Elementos de diseño vectoriales animados (experimental)
Figura 1: Elemento de diseño vectorial animado en Compose
Para usar un recurso AnimatedVectorDrawable, carga el archivo de elemento de diseño usando animatedVectorResource y pasa un boolean para alternar entre el estado inicial y final de tu elemento de diseño, y realizar la animación.
El contenido y las muestras de código que aparecen en esta página están sujetas a las licencias que se describen en la Licencia de Contenido. Java y OpenJDK son marcas registradas de Oracle o sus afiliados.
Última actualización: 2025-08-27 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-27 (UTC)"],[],[],null,["Animating vectors in Compose is possible in a few different ways. You can use any of the following:\n\n- `AnimatedVectorDrawable` file format\n- `ImageVector` with Compose animation APIs, like in [this Medium article](https://medium.com/androiddevelopers/making-jellyfish-move-in-compose-animating-imagevectors-and-applying-agsl-rendereffects-3666596a8888)\n- A third-party solution like [Lottie](https://airbnb.design/lottie/)\n\nAnimated vector drawables (experimental) **Figure 1.** Animated vector drawable in Compose\n\nTo use an [`AnimatedVectorDrawable`](/reference/android/graphics/drawable/AnimatedVectorDrawable) resource, load up the drawable file using `animatedVectorResource` and pass in a `boolean` to switch between the start and end state of your drawable, performing the animation.\n\n\n```kotlin\n@Composable\nfun AnimatedVectorDrawable() {\n val image = AnimatedImageVector.animatedVectorResource(R.drawable.ic_hourglass_animated)\n var atEnd by remember { mutableStateOf(false) }\n Image(\n painter = rememberAnimatedVectorPainter(image, atEnd),\n contentDescription = \"Timer\",\n modifier = Modifier.clickable {\n atEnd = !atEnd\n },\n contentScale = ContentScale.Crop\n )\n}https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/animations/AnimationSnippets.kt#L915-L927\n```\n\n\u003cbr /\u003e\n\nFor more information about the format of your drawable file, see [Animate drawable graphics](/guide/topics/graphics/drawable-animation).\n\nRecommended for you\n\n- Note: link text is displayed when JavaScript is off\n- [Loading images {:#loading-images}](/develop/ui/compose/graphics/images/loading)"]]