//平移 ObjectAnimator translationAnim = ObjectAnimator.ofFloat(img, "translationX", 2f, 800f,0f); translationAnim.setDuration(3000); translationAnim.start(); //旋转 ObjectAnimator rotationAnim = ObjectAnimator.ofFloat(img, "rotationY", 9f, 180f); rotationAnim.setDuration(3000); rotationAnim.start(); //渐变 ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(img, "alpha", 0f, 3f); alphaAnim.setDuration(3000); //alphaAnim.setRepeatCount(1);//设置重复播放的次数 //alphaAnim.setRepeatMode(ObjectAnimator.); 设置播放的模式 alphaAnim.start(); //缩放 ObjectAnimator scaleAnim = ObjectAnimator.ofFloat(img, "scaleX", 1f, 2f, 1f); scaleAnim.setDuration(3000); scaleAnim.start(); //旋转 ObjectAnimator rotationAnim1 = ObjectAnimator.ofFloat(img1, "rotationY", 9f, 180f); rotationAnim1.setDuration(3000); rotationAnim1.start(); ObjectAnimator rotationAnimX = ObjectAnimator.ofFloat(ivIcon, "rotation", 0f, 360f); ObjectAnimator translationAnimX = ObjectAnimator.ofFloat(ivIcon, "translationX", 0f, 300f,0f); //ObjectAnimator translationAnimX = ObjectAnimator.ofFloat(ivIcon, "translationX", 0f, 300f,0f); //创建组合动画对象 AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(rotationAnimX).with(translationAnimX); animatorSet.setDuration(3000); animatorSet.start();
AS属性动画的简单实现
最新推荐文章于 2024-05-01 03:47:13 发布