Comment charger animateur fichier xml sur Android par programmation?

Selon le site des développeurs Android, nous pouvons charger AnimatorSet classe par programmation à partir du fichier xml situé sur le chemin comme ceci: res/animator/filename.xml. J'ai donc créé un exemple de projet et essayé de voir si cela fonctionne réellement, et il n'en est rien; il ne se passe rien. Il serait très bien si je peux comprendre ce qui est manquant et/ou ce que j'ai fait de mal. Merci à l'avance! Ci-dessous est mon animateur fichier xml et le code Java permettant de charger le xml:

res/animator/sample.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:ordering="sequentially"
    >
  <set>
    <objectAnimator
        android:propertyName="x"
        android:duration="500"
        android:valueTo="400"
        android:valueType="intType"
        />
    <objectAnimator
        android:propertyName="y"
        android:duration="500"
        android:valueTo="300"
        android:valueType="intType"
        />
  </set>
  <objectAnimator
      android:propertyName="alpha"
      android:duration="500"
      android:valueTo="1f"
      />
</set>

Et voici mes codes Java pour charger le fichier xml ci-dessus:

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();
  }
});

OriginalL'auteur shoheikawano | 2015-11-16