//渐变动画 public void gradual(View view){ ObjectAnimator animator=ObjectAnimator.ofFloat(img,"alpha",1f,0f,1f); animator.setDuration(3000); animator.start(); } //旋转动画 public void rotate(View view){ ObjectAnimator animator=ObjectAnimator.ofFloat(img,"rotation",0f,360f,0f); animator.setDuration(3000); animator.start(); } //平移动画 public void translation(View view){ ObjectAnimator animator=ObjectAnimator.ofFloat(img,"translationX",0f,200f,0f); animator.setDuration(3000); animator.start(); } //集合动画 public void synthesize(View view){ ObjectAnimator suo=ObjectAnimator.ofFloat(img,"scaleY",1f,2f,1f); ObjectAnimator animator=ObjectAnimator.ofFloat(img,"scaleX",1f,0f,1f); ObjectAnimator ping=ObjectAnimator.ofFloat(img,"translationX",0f,200f,0f); ObjectAnimator tou=ObjectAnimator.ofFloat(img,"alpha",1f,0f,1f); AnimatorSet as=new AnimatorSet(); as.play(suo).with(animator).with(tou).before(ping); as.setDuration(3000); as.start(); } //缩放 public void zoom(View view){ ObjectAnimator animator=ObjectAnimator.ofFloat(img,"scaleX",1f,2f,1f); animator.setDuration(3000); animator.start(); }
属性动画的几种简单用途
最新推荐文章于 2023-10-20 09:17:24 发布