Android 闪烁动画

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;

/*闪烁效果*/
public class AlphaAnimationUtil {

    /**
     * 开启View闪烁效果
     * */
    public static void startFlick(View view ){

        if( null == view ){
            return;
        }

        Animation alphaAnimation = new AlphaAnimation( 1.0f, 0.5f );
        alphaAnimation.setDuration( 300 );
        alphaAnimation.setFillBefore(true);
        alphaAnimation.setInterpolator( new LinearInterpolator( ) );
        alphaAnimation.setRepeatCount( Animation.INFINITE );
        alphaAnimation.setRepeatMode( Animation.REVERSE );
        view.startAnimation( alphaAnimation );
    }

    /**
     * 取消View闪烁效果
     * */
    public static void stopFlick( View view ){
        if( null == view ){
            return;
        }
        view.clearAnimation( );
    }
}

 

posted @ 2018-07-18 11:17  _York  阅读(...)  评论(...编辑  收藏