我试图为VectorDrawable路径变形设置动画,但由于某种原因,路径变形是唯一不起作用的事情(改变颜色等工作正常)。 这是我的Drawable:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="170"
android:viewportHeight="170"
android:width="500dp"
android:height="500dp">
<path
android:name="head"
android:fillColor="@color/colorPrimary"
android:pathData="M85,40
c10,0 20,0 30,0
c0,-5 -10,-20 -30,-20
c-20,0 -30,15 -30,20
c10,0 20,0 30,0"/>
</vector>
AnimatedVectorDrawable:
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/vector_drawable">
<target
android:animation="@animator/path_morph"
android:name="head"/>
</animated-vector>
动画本身:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially">
<objectAnimator
android:duration="200"
android:propertyName="pathData"
android:valueType="pathType"
android:valueFrom="M85,40
c10,0 20,0 30,0
c0,-5 -10,-20 -30,-20
c-20,0 -30,15 -30,20
c10,0 20,0 30,0"
android:valueTo="M108,35
c5.587379,-6.7633 9.348007,-16.178439 8.322067,-25.546439
c-8.053787,0.32369 -17.792625,5.36682 -23.569427,12.126399
c-5.177124,5.985922 -9.711121,15.566772 -8.48777,24.749359
c8.976891,0.69453 18.147476,-4.561718 23.73513,-11.329308"/>
<objectAnimator
android:duration="200"
android:propertyName="fillColor"
android:valueFrom="@color/colorPrimary"
android:valueTo="@color/colorAccent"
/>
</set>
这是我开始动画的方式:
((Animatable)binding.image.getDrawable()).start();
出了什么问题?
看起来我发现了一些内容:如果我将其设置为TextView
(&#39; bottomDrawable&#39;例如),或者将其设置为ImageView
,它就可以正常工作android:src
而非app:srcCompat
。这是一个错误吗?