- 首页 > it技术 > >
ObjectAnimator|ObjectAnimator 属性动画 和组合
//获取屏幕高
int wallpaperDesiredMinimumHeight = context.getWallpaperDesiredMinimumHeight();
//平移
ObjectAnimator translationY = ObjectAnimator.ofFloat(view, "translationY", wallpaperDesiredMinimumHeight / 2 - 100);
//旋转
ObjectAnimator rotation = ObjectAnimator.ofFloat(view, "rotation",0,360);
//透明
ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 0 ,1);
//缩放
ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX",2,1);
//组合
AnimatorSet aa=new AnimatorSet();
//aa.playSequentially(translationY,rotation,alpha,scaleX);
aa.playTogether(translationY,rotation,alpha,scaleX);
aa.setDuration(3000);
aa.start();
//事件
aa.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {}@Override
public void onAnimationEnd(Animator animator) {
iView.succeed();
}@Override
public void onAnimationCancel(Animator animator) {}@Override
public void onAnimationRepeat(Animator animator) {}
});
推荐阅读