Add ObjectAnimator to AnimatedVectorDrawable at Run Time

I can change fillColor for AnimatedVectorDrawable using xml files.

<?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> 

  mImageView = (ImageView)findViewById(R.id.ImageView); Drawable drawable = mImageView.getDrawable(); if (drawable instanceof Animatable) { ((Animatable) drawable).start(); } 

But is there a way to change color at runtime?

+7
android android-5.0-lollipop android-drawable
source share

No one has answered this question yet.

See related questions:

947
Android Studio: add jar as a library?
17
Error: onNewIntent is not called for singleTop activity with Intent.FLAG_ACTIVITY_NEW_TASK
eleven
Android - Google Maps API v2 - NoClassDefFoundError
2
Android + Facebook SDK: "The application could not be authenticated due to an application name mismatch."
2
Incorrect overflow menu location
2
Android - tiled backgrounds sometimes stretch
0
Android app cannot deploy on virtual device
0
How to fix "Application Launch Error: No default activity found"
0
Help with a transparent list
0
How to add a banner ad (banner ad) Top or bottom of the image?

All Articles