码迷,mamicode.com
首页 > 其他好文 > 详细

动画基础

时间:2017-11-01 01:02:20      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:text   val   set   imageview   oid   平滑   get   float   bsp   

 // ValueAnimator anim=ValueAnimator.ofFloat(0f,1f);整数过度
//从0平滑过渡到1,时间为300毫秒

final ValueAnimator anim = ValueAnimator.ofFloat(0f, 300f);
anim.setDuration(300);
anim.start();
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float currentValue = (float) animation.getAnimatedValue();
Log.d("TAG", "current value is " + currentValue);
}
});*/
// alpha透明
ObjectAnimator animator=ObjectAnimator.ofFloat(imageView,"alpha"1f,0f,1f);

// rotation 旋转
 ObjectAnimator animator=ObjectAnimator.ofFloat(imageView,"rotation",0f,360f);

animator.setDuration(5000);
animator.start();
//移出屏幕外
float x=imageView.getTranslationX();
ObjectAnimator animator=ObjectAnimator.ofFloat(imageView,"translationX",x,-500f,x);
Y轴缩放
ObjectAnimator animator=ObjectAnimator.ofFloat(imageView,"scaleY",1f,3f,1f);
组合动画
ObjectAnimator moveIn=ObjectAnimator.ofFloat(textView,"translationX",-500f,0f);
ObjectAnimator roate=ObjectAnimator.ofFloat(textView,"rotation",0f,360f);
ObjectAnimator fadeInOut=ObjectAnimator.ofFloat(textView,"alpha",1f,0f,1f);
AnimatorSet animatorSet=new AnimatorSet();
animatorSet.play(roate).with(fadeInOut).after(moveIn);
animatorSet.setDuration(5000);
animatorSet.start();
 

动画基础

标签:text   val   set   imageview   oid   平滑   get   float   bsp   

原文地址:http://www.cnblogs.com/CY-947205926/p/7764400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!