@OnClick(R.id.translateAndFade)
public void onTranslateAndFade() {
ValueAnimator xAnimator = ObjectAnimator.ofFloat(icon, "translationX", icon.getTranslationX(), animateForward ? icon.getWidth() * 2 : 0.0f);
ValueAnimator yAnimator = ObjectAnimator.ofFloat(icon, "translationY", icon.getTranslationY(), animateForward ? icon.getHeight() * 4 : 0.0f);
ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(icon, "alpha", icon.getAlpha(), animateForward ? 0.0f : 1.0f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(FULL_ANIMATION_DURATION);
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
animatorSet.playTogether(xAnimator, yAnimator, alphaAnimator);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
System.out.println("translateAndFade END");
}
});
animatorSet.start();
animateForward = !animateForward;
}
ObjectAnimatorActivity.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:AnimationShowcase
作者:
评论列表
文章目录