android - 如何在 Compose 中使用动画矢量可绘制对象

标签 android android-jetpack-compose android-drawable android-image android-vectordrawable

我创建了我的矢量可绘制动画,我想在 Compose 中使用。我在 official documentation 中找到我需要调用 animatedVectorResource。但是整个 AnimatedImageVector 已经从 compose 中删除,直到下一个版本。如何在当前 Compose 版本中启动动画绘图?

最佳答案

您需要将 compose 更新到 1.1.0-alpha01 并添加模块 androidx.compose.animation:animation-graphics,如上一个更新日志中所示

enter image description here

implementation("androidx.compose.animation:animation-graphics:1.1.0-alpha01")
val image = animatedVectorResource(id = R.drawable.animated_vector)
val atEnd by remember { mutableStateOf(false) }
Icon(
   painter = image.painterFor(atEnd = atEnd),
   contentDescription = null
)

关于android - 如何在 Compose 中使用动画矢量可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68672046/

相关文章:

android - 使用 Node js 向 google ccs 发送下游消息

android - 我们如何在模拟器上测试 Google Map API v2

android - 如何在 jetpack compose Lazy Column 上实现反弹效果

android - 带有水平线和中间圆圈的可绘制 xml

java - 返回 Activity 的 fragment

android - 无法在 Android Studio 中生成已签名的 APK,因为缺少 proguard-rules.txt

android - Jetpack Compose LazyRow 滚动仅捕捉到下一个或上一个元素的开始

kotlin - collectAsState 未从存储库接收更改

android - 弧形矩形机器人

android - 如何构建垂直分隔线