sta*_*ack 8 android android-drawable android-5.0-lollipop animatedvectordrawable
我可以使用xml文件更改AnimatedVectorDrawable的fillColor.
<?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>
Run Code Online (Sandbox Code Playgroud)
mImageView = (ImageView)findViewById(R.id.ImageView);
Drawable drawable = mImageView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
Run Code Online (Sandbox Code Playgroud)
但有没有办法在运行时改变颜色?
| 归档时间: |
|
| 查看次数: |
679 次 |
| 最近记录: |