Я следую этому учебнику , чтобы использовать AnimatedVectorDrawableCompat
.
Вот мой animatedVectorDrawable xml:
<animated-vector xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="50dp"
android:viewportWidth="100"
android:viewportHeight="50"
tools:targetApi="lollipop">
<group
android:name="group"
android:translateY="-22">
<path
android:name="path_1"
android:pathData="M 6 52 L 27 52 L 32 51 L 36 55 L 46 26 L 56 69 L 61 50 L 66 56 L 70 50 L 74 52 L 94 52"
android:strokeColor="#1871ba"
android:strokeWidth="6"
android:strokeLineCap="round"
android:strokeLineJoin="round"/>
</group>
</vector>
</aapt:attr>
<target android:name="path_1">
<aapt:attr name="android:animation">
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:propertyName="trimPathEnd"
android:duration="500"
android:valueFrom="0"
android:valueTo="1"
android:valueType="floatType"
android:repeatMode="restart"
android:repeatCount="infinite"
android:interpolator="@android:anim/decelerate_interpolator" />
<objectAnimator
android:propertyName="trimPathStart"
android:startOffset="500"
android:duration="500"
android:valueFrom="0"
android:valueTo="1"
android:repeatMode="restart"
android:repeatCount="infinite"
android:valueType="floatType"
android:interpolator="@android:anim/decelerate_interpolator"/>
</set>
</aapt:attr>
</target>
</animated-vector>
Почему я получаю ошибка времени выполнения при использовании Binary XML file line #1: invalid drawable tag animated-vector
?
Компактная библиотека должна была решить эту проблему. нет?
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/heart_rate.xml from drawable resource ID #0x7f0800a2
at android.content.res.Resources.loadDrawable(Resources.java:2096)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.ImageView.<init>(ImageView.java:127)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:74)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:69)
at android.support.v7.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:199)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:119)
at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1548)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1599)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:172)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.google.android.libraries.onegoogle.catalogapp.accountparticledisc.AccountParticleDiscDemoFragment.onCreateView(AccountParticleDiscDemoFragment.java:51)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2755)
at android.support.v4.app.FragmentStateManager.createView(FragmentStateManager.java:478)
at android.support.v4.app.FragmentManager.moveToState(FragmentManager.java:1259)
at android.support.v4.app.FragmentManager.moveToState(FragmentManager.java:1405)
at android.support.v4.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1483)
at android.support.v4.app.FragmentManager.moveToState(FragmentManager.java:1549)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:454)
at android.support.v4.app.FragmentManager.executeOps(FragmentManager.java:2269)
at android.support.v4.app.FragmentManager.executeOpsTogether(FragmentManager.java:2058)
at android.support.v4.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1996)
at android.support.v4.app.FragmentManager.execPendingActions(FragmentManager.java:1898)
at android.support.v4.app.FragmentManager$5.run(FragmentManager.java:460)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag animated-vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:897)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:837)
at android.content.res.Resources.loadDrawable(Resources.java:2092)