Create TranslateAnimation : TranslateAnimation « Animation « Android






Create TranslateAnimation

  
//package jp.mrshiromi.net.onamaenaani.util;

import android.content.Context;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.OvershootInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

class AnimUtil {
  public static Animation createKumoAnimation(Context context) {
    AnimationSet set = new AnimationSet(true);

    ScaleAnimation sa = new ScaleAnimation(0.98f, 1.02f, 0.98f, 1.02f,
        Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
        0.5f);
    sa.setDuration(12000);
    sa.setRepeatMode(Animation.REVERSE);
    sa.setRepeatCount(5);

    TranslateAnimation ta = new TranslateAnimation(
        Animation.RELATIVE_TO_SELF, -0.05f, Animation.RELATIVE_TO_SELF,
        0.05f, Animation.RELATIVE_TO_SELF, 0f,
        Animation.RELATIVE_TO_SELF, 0f);
    ta.setDuration(6000);
    ta.setRepeatMode(Animation.REVERSE);
    ta.setRepeatCount(10);

    set.addAnimation(sa);
    set.addAnimation(ta);
    set.setFillAfter(true);

    return set;
  }
}

   
    
  








Related examples in the same category

1.Translate and alpha animation