补间动画

主要的方法:

1.透明:AlphaAnim
2.旋转 rotateAnim
3.缩放 ScaleAnim
4.位移 translateAnim
原理:动画效果不会改变控件真实坐标
1.实现透明

AlphaAnimation aa = new AlphaAnimation(1.0f,0.0f);//1.0代表完全不透明,0.0代表透明
aa.setDuration(3000);//实行的时间
aa.setRepeatCount(2);//执行次数
aa.setRepeatMode(Animation.REVERSE);//设置重复模式
//开启
iv.startAnimation(aa);

2.旋转
 RotateAnimation ad = new RotateAnimation(0,360,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
ad.setDuration(2000);
ad.setRepeatCount(2);
ad.setRepeatMode(Animation.RESTART);
iv.startAnimation(ad);
3.缩放
ScaleAnimation ad = new ScaleAnimation(1.0f,2.0f,1.0f,2.0f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
ad.setDuration(3000);
ad.setRepeatMode(2);
ad.setRepeatMode(Animation.RESTART);//是设置重复值
iv.startAnimation(ad);
4.移动位置
TranslateAnimation ta = new TranslateAnimation(RELATIVE_TO_PARENT,0, RELATIVE_TO_PARENT,0,
RELATIVE_TO_PARENT,0,RELATIVE_TO_PARENT,0.2f);
ta.setDuration(3000);
ta.setFillAfter(true);//停在最后位置
iv.startAnimation(ta);


原文地址:https://www.cnblogs.com/lyl123/p/7147297.html