我找不出爲什麼我的動畫矢量不起作用。我可以看到第一個路徑,但第二個路徑是我想要添加第一個路徑的動畫,但未顯示。這是我的代碼看起來像:動畫矢量可繪製動畫不起作用
<?xml version="1.0" encoding="utf-8"?>
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:height="24dp"
android:width="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0" >
<path
android:name="v"
android:strokeColor="#000000"
android:strokeWidth="3"
android:pathData="M6,11 l3.5, 4 l0, 0" />
</vector>
</aapt:attr>
<target android:name="v" >
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:duration="1000"
android:propertyName="pathData"
android:valueFrom="M6,11 l3.5, 4 l0, 0"
android:valueTo="M6,11 l3.5, 4 l8, -7"
android:valueType="pathType"/>
</set>
</aapt:attr>
</target>
</animated-vector>
所以,M6,11 l3.5, 4 l0, 0
正顯示在屏幕上,但不M6,11 l3.5, 4 l8, -7
我試圖複製例如,從谷歌文檔here的底部並沒有工作。如果我使用他們的代碼告訴我我正確地開始動畫,我的文件就會正確地動畫。這是我的路徑數據的錯字或錯誤嗎?
通過使用'android:src'而不是'app:srcCompat',你實際上繞過了支持庫,所以它的版本根本不相關。不過要小心,不使用支持庫,你的drawable將會在21以下的API上崩潰。 –