Create RotateAnimation : RotateAnimation « Animation « Android






Create RotateAnimation

 
//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 createAnimation(Context context) {
    AnimationSet set = new AnimationSet(true);

    RotateAnimation ra = new RotateAnimation(-8, 8,
        Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
        0.5f);
    ra.setDuration(6000);
    ra.setRepeatMode(Animation.REVERSE);
    ra.setRepeatCount(10);

    ScaleAnimation sa = new ScaleAnimation(0.95f, 1.05f, 0.95f, 1.05f,
        Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
        0.5f);
    sa.setDuration(6000);
    sa.setRepeatMode(Animation.REVERSE);
    sa.setRepeatCount(10);

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

    return set;
  }
}

   
  








Related examples in the same category