我用了属性动画,但是在内存低的手机上跑了一下感觉卡卡的,但是贵金属的就不卡
,属性动画和补间动画相比效率上比较差吗,
这是我的代码
private void setFirstAnimation() {
if (firstAnimationState == 0) {
firstAnimationState = 1;
ObjectAnimator anim1 = ObjectAnimator.ofFloat(iv_first_calculator,
"x", PhoneParameterUtils.getScreenWidth() / 2f - 200f - 323f,
(PhoneParameterUtils.getScreenWidth() / 2f) - AppTools.dip2px(100)).setDuration(400);
anim1.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
AnimatorSet set = new AnimatorSet();
ObjectAnimator anim2 = ObjectAnimator.ofFloat(iv_first_ball,
"x", PhoneParameterUtils.getScreenWidth() / 2,
PhoneParameterUtils.getScreenWidth() / 2 + AppTools.dip2px(40)).setDuration(400);
ObjectAnimator anim3 = ObjectAnimator.ofFloat(iv_first_ball,
"y", PhoneParameterUtils.getScreenHeight() / 2 - AppTools.dip2px(120),
PhoneParameterUtils.getScreenHeight() / 2 - AppTools.dip2px(150)).setDuration(400);
set.playTogether(anim2, anim3);
set.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
iv_first_ball.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animator) {
AnimatorSet set = new AnimatorSet();
ObjectAnimator anim4 = ObjectAnimator.ofFloat(iv_first_man,
"x", PhoneParameterUtils.getScreenWidth(),
PhoneParameterUtils.getScreenWidth() / 2).setDuration(500);
ObjectAnimator anim5 = ObjectAnimator.ofFloat(iv_first_man,
"x", PhoneParameterUtils.getScreenWidth() / 2,
PhoneParameterUtils.getScreenWidth() / 2 + 10).setDuration(20);
ObjectAnimator anim6 = ObjectAnimator.ofFloat(iv_first_man,
"x", PhoneParameterUtils.getScreenWidth() / 2 + 10,
PhoneParameterUtils.getScreenWidth() / 2).setDuration(20);
set.playSequentially(anim4, anim5, anim6);
iv_first_man.setVisibility(View.VISIBLE);
set.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
firstAnimationState = 0;
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
set.start();
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
set.start();
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
anim1.start();
}
}
找到原因了,用了几个大的图,放到了drawable-hdpi中的 囧啊
也许人家直接是一个短视频