Animationen in XML für ViewAnimator

  • 0 Antworten
  • Letztes Antwortdatum
Keine_Angabe

Keine_Angabe

Ambitioniertes Mitglied
9
Hallo,
ich habe einen ViewAnimator und Animationen in Java-Code wie z.B:
Code:
private Animation inFromLeftAnimation() {
        Animation inFromLeft = new TranslateAnimation(
                Animation.RELATIVE_TO_PARENT, -1.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f);
        inFromLeft.setDuration(500);
        inFromLeft.setInterpolator(new AccelerateInterpolator());
        return inFromLeft;
    }
Damit will ich die Views In- bzw. Out-Sliden. Das funktioniert auch wie gewünscht. Jetzt möchte ich aber die Animationen in XML Files packen und diese dann laden, aber hier ist das Problem. Es werden keine Animationen angezeigt. Irgendwas muss in meinen XML Files falsch sein. Hier ist mal ein Auszug (in_from_left.xml):
Code:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android">
         android:interpolator="@android:anim/accelerate_interpolator"
         android:duration="500"
        android:fromXType="Animation.RELATIVE_TO_PARENT"
        android:fromXValue="-1.0f"
        android:toXType="Animation.RELATIVE_TO_PARENT"
        android:toXValue="0.0f"
        android:fromYType="Animation.RELATIVE_TO_PARENT"
        android:fromYValue="0.0f"
        android:toYType="Animation.RELATIVE_TO_PARENT"
        android:toYValue="0.0f"   
</translate>
Der Aufruf ist dann:
Code:
va.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.in_from_left));

Was passiert ist nur der Wechsel des Views, aber keine Animation.

Viele Grüße
 
Zurück
Oben Unten