场景:我在 ImageView 中有一个形状为 AnimatedVectorDrawable 实例。单击此形状( ImageView )时,它将执行动画。此动画结束后,将执行一个新的 Activity 。然后,使用智能手机上的返回按钮时,将显示第一个 Activity 。为了使 AnimatedVectorDrawable 以其原始状态显示(不应用动画),可以在android sdk 23版以上调用reset()方法。示例:
public void onStop() {
super.onStop();
avdLogo.reset()
}
avdLogo 是指正在讨论的 AnimatedVectorDrawable 。
如何在23版以下实现相同的功能?
答案 0 :(得分:1)
将vectorDrawables.useSupportLibrary = true
添加到模块build.gradle的android部分的defaultConfig中。像下面一样
android {
........
........
defaultConfig {
........
vectorDrawables.useSupportLibrary = true
}
它将支持动画矢量可绘制文件,以便与低于Lollipop的API兼容使用。