title: How to add Animated Vector Drawable Animation?
body: <p>I am trying to animate a vector path to a different path in my android app for testing but its not working properly . no animation is displayed on screen and neither any animation is shown.</p>
  
  <p><strong>My vector file is:</strong></p>
  
  <pre><code>    &lt;vector xmlns:android="http://schemas.android.com/apk/res/android"
      android:width="8dp"
      android:height="5dp"
      android:viewportWidth="8"
      android:viewportHeight="5"&gt;
    &lt;path
        android:name="redot"
        android:pathData="M2.5,2.5L6,2.5"
        android:strokeWidth="4"
        android:fillColor="#00000000"
        android:strokeColor="#E61B1B"
        android:fillType="evenOdd"
        android:strokeLineCap="round"/&gt;
  &lt;/vector&gt;
  </code></pre>
  
  <p><strong>And my VectorAnimation file is:</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;animated-vector xmlns:tools="http://schemas.android.com/tools"
          xmlns:android="http://schemas.android.com/apk/res/android"
          tools:targetApi="lollipop"
          android:drawable="@drawable/ic_reddot"&gt;
  
  
          &lt;target
              android:animation="@anim/redanim"
              android:name="redot"/&gt;
  
      &lt;/animated-vector&gt;
  </code></pre>
  
  <p><strong>My Animation file in anim folder is:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
      &lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
          &lt;objectAnimator
              android:duration="10000"
              android:propertyName="pathData"
              android:valueFrom="M2.5,2.5L6,2.5"
              android:valueTo="M2.5,2.5L31,2.5"
              android:valueType="pathType" /&gt;
  
      &lt;/set&gt;
  </code></pre>
  
  <p><strong>And finally my MainActivityCode is as following:</strong></p>
  
  <pre><code>    public class MainActivity extends AppCompatActivity {
      private TextView testObj;
      private ImageView reddot;
      private AnimatedVectorDrawable animation;
  
      @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
        // testObj = (TextView) findViewById(R.id.testObj);
       // testObj.setVisibility(View.INVISIBLE);
      reddot = (ImageView) findViewById(R.id.reddot);
  
                 Drawable d =  reddot.getBackground();
              if (d instanceof AnimatedVectorDrawable) {
                  Log.d("testanim", "onCreate: instancefound" );
                  animation = (AnimatedVectorDrawable) d;
                  animation.start();
              }
  
          }
      }
  </code></pre>