Jetpack Compose 中可绘制动画的替代方案是什么
What is Alternative of Animation drawable in Jetpack Compose
我正在尝试在 Jetpack Compose 中实现帧动画。
我知道在android视图系统中,可以使用AnimationDrawable来实现。
但是如何在 Jetpack Compose 中正确使用可绘制动画 class?
最后我找到了一个 solution.I 使用 jetpack 中的可绘制动画实现的帧动画,通过以编程方式创建可绘制动画并将其分配给图像,因为 Drawable.Finally 使用动画可绘制引用来控制 animation.I 我正在发布下面的示例代码...
val animationDrawable = AnimationDrawable()
//add your images in animationDrawable by giving information of duration etc like you gave in xml file..
Image(
painter = rememberDrawablePainter(animationBlast),
contentDescription = null,
Modifier
.offset {
IntOffset(
offsetX.toInt() - (if (size == 250) 300 else 0),
offsetY.toInt() - (if (size == 250) 300 else 0)
)
}
.size(size.dp), contentScale = ContentScale.Crop
)
animationDrawable?.start()
我正在尝试在 Jetpack Compose 中实现帧动画。
我知道在android视图系统中,可以使用AnimationDrawable来实现。
但是如何在 Jetpack Compose 中正确使用可绘制动画 class?
最后我找到了一个 solution.I 使用 jetpack 中的可绘制动画实现的帧动画,通过以编程方式创建可绘制动画并将其分配给图像,因为 Drawable.Finally 使用动画可绘制引用来控制 animation.I 我正在发布下面的示例代码...
val animationDrawable = AnimationDrawable()
//add your images in animationDrawable by giving information of duration etc like you gave in xml file..
Image(
painter = rememberDrawablePainter(animationBlast),
contentDescription = null,
Modifier
.offset {
IntOffset(
offsetX.toInt() - (if (size == 250) 300 else 0),
offsetY.toInt() - (if (size == 250) 300 else 0)
)
}
.size(size.dp), contentScale = ContentScale.Crop
)
animationDrawable?.start()