Android 在运行时将ObjectAnimator添加到AnimatedVectorDrawable
我可以通过使用xml文件更改动画VectorDrawable的填充颜色Android 在运行时将ObjectAnimator添加到AnimatedVectorDrawable,android,android-5.0-lollipop,android-drawable,animatedvectordrawable,Android,Android 5.0 Lollipop,Android Drawable,Animatedvectordrawable,我可以通过使用xml文件更改动画VectorDrawable的填充颜色 <?xml version="1.0" encoding="utf-8"?> <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/my_svg"> <target android:animation="@ani
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/my_svg">
<target
android:animation="@animator/myanimator"
android:name="color" />
</animated-vector>
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="3000"
android:propertyName="fillColor"
android:valueType="intType"
android:interpolator="@android:interpolator/decelerate_cubic"
android:valueFrom="@color/blue"
android:valueTo="@color/green" />
</set>
但是有没有办法在运行时更改颜色?您最终找到了解决方案吗?我看不到访问AnimatedVectorDrawable的动画师的方法。我觉得这很傻。
mImageView = (ImageView)findViewById(R.id.ImageView);
Drawable drawable = mImageView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}