Using AlphaAnimation : AlphaAnimation « Animation « Android






Using AlphaAnimation

  
//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 final int CLICK_DURATION = 3000;

  public static Animation createShabonClickAnimation() {
    AnimationSet set = new AnimationSet(true);

    AlphaAnimation aa = new AlphaAnimation(0.5f, 1f);
    aa.setDuration(CLICK_DURATION / 10);
    aa.setRepeatMode(Animation.REVERSE);
    aa.setRepeatCount(CLICK_DURATION / (CLICK_DURATION / 10));

    ScaleAnimation sa = new ScaleAnimation(0.99f, 1.0f, 0.99f, 1.0f,
        Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
        0.5f);
    sa.setDuration(CLICK_DURATION / 10);
    sa.setRepeatMode(Animation.REVERSE);
    sa.setRepeatCount(CLICK_DURATION / (CLICK_DURATION / 10));

    AlphaAnimation aa2 = new AlphaAnimation(1f, 0f);
    aa2.setDuration(CLICK_DURATION / 10);
    aa2.setStartOffset(CLICK_DURATION - CLICK_DURATION / 10);

    set.addAnimation(aa);
    set.addAnimation(sa);
    set.addAnimation(aa2);
    set.setFillAfter(true);

    return set;
  }

}

   
    
  








Related examples in the same category

1.Utility for slide down and slide up