【Android中最近使用的动画总结】1.缩放动画
2.位移动画(方法以及参数含义)
3.属性动画
4.组合动画
ObjectAnimator scaleX = ObjectAnimator.ofFloat(holder.svGiftImg, "scaleX", 0f,1.3f, 1f);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(holder.svGiftImg, "scaleY", 0f, 1.3f, 1f);
ObjectAnimator alpha = ObjectAnimator.ofFloat(holder.svGiftImg, "alpha", 1f, 0f);
AnimatorSet animatorSet = new AnimatorSet();
//可以设置执行顺序
animatorSet.play(scaleX).with(scaleY).before(alpha);
alpha.setStartDelay(600);
animatorSet.setDuration(500);
alpha.setDuration(200);
animatorSet.setInterpolator(new LinearInterpolator());
animatorSet.start();
AnimationSet animationSet = new AnimationSet(true);
TranslateAnimation transAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,Animation.RELATIVE_TO_SELF,0f,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, -0.8f);
AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f,0f);
animationSet.addAnimation(transAnimation);
animationSet.addAnimation(alphaAnimation);
//animationSet与animatorSet区别是前者可以设置setFillAfteranimationSet.setFillAfter(false);
animationSet.setDuration(1000);
alphaAnimation.setDuration(700);
//使用setStartOffset设置动画执行顺序
alphaAnimation.setStartOffset(500);
animationSet.setInterpolator(new LinearInterpolator());
animationSet.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}@Override
public void onAnimationEnd(Animation animation) {holder.tvGetIntegral.setVisibility(View.INVISIBLE);
}@Override
public void onAnimationRepeat(Animation animation) {
}
});
view. startAnimation(animationSet);
推荐阅读
- 每天记录学习的新知识 : ObjectAnimator 基础和用法
- loading|水流波动效果的进度条
- Android|Android 补间动画(动画列表,平移,旋转,缩放,渐变,动画集合)
- android|Android Animator(Android动画)
- android|Android Animator的使用
- ObjectAnimator实用方法
- Android|极简源码之Android ObjectAnimator实现原理
- android|Android 值动画一(ObjectAnimator)
- web前端|HTML5 Canvas可拖动的弹性大树摇摆动画