是否可以通过编程方式更改android中Rive动画元素的参数?
我有一个 Rive 动画,我需要以编程方式更改其元素之一的颜色。 我在 Rive 的文档和示例中没有找到任何内容。
我确实能够使用
控制 Rive 动画 if(binding.bus.isPlaying) {
binding.bus.controller.pause()
}
else {
binding.bus.controller.play()
}
或更改 Rive 来源
val queue = Volley.newRequestQueue(context)
val stringRequest = RiveFileRequest(
"https://cdn.rive.app/animations/vehicles.riv",
{ file -> binding.bus.setRiveFile(file) },
{ throw IOException("Unable to download Rive file") }
)
queue.add(stringRequest)
更多您可以从这里查看源代码: https://github.com/rive-app/rive-android/blob/master/kotlin/src/main/java/app/rive/runtime/kotlin/RiveAnimationView.kt#L625