title: How to load animator xml file on Android programatically?
body: <p>According to <a href="https://developer.android.com/guide/topics/resources/animation-resource.html" rel="noreferrer">the Android developer site</a>, we can load <code>AnimatorSet</code> class programatically from xml file located on the path like this: <code>res/animator/filename.xml</code>. So I have created a sample project and tried to see if it actually works, and it doesn't; nothing happens. It would be very nice if I can understand what is missing and/or what I have done wrong. Thanks in advance! Below is my animator xml file and Java code to load the xml:</p>
  
  <p>res/animator/sample.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;set xmlns:android="http://schemas.android.com/apk/res/android"
      android:ordering="sequentially"
      &gt;
    &lt;set&gt;
      &lt;objectAnimator
          android:propertyName="x"
          android:duration="500"
          android:valueTo="400"
          android:valueType="intType"
          /&gt;
      &lt;objectAnimator
          android:propertyName="y"
          android:duration="500"
          android:valueTo="300"
          android:valueType="intType"
          /&gt;
    &lt;/set&gt;
    &lt;objectAnimator
        android:propertyName="alpha"
        android:duration="500"
        android:valueTo="1f"
        /&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p>And here is my Java codes to load the xml file above:</p>
  
  <pre><code>FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  fab.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View view) {
      // Load and start Animaton
      AnimatorSet animSet =
          (AnimatorSet) AnimatorInflater.loadAnimator(view.getContext(), R.animator.sample);
      animSet.setTarget(view);
      animSet.start();
    }
  });
  </code></pre>