AnimationSet animationSet = new AnimationSet(true); RotateAnimation rotateAnimation = new RotateAnimation(Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF, 0,Animation.RELATIVE_TO_SELF,Animation.RELATIVE_TO_SELF, 0); /** * 平移(左右) */ // Animation translateAnimation3 = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0f, // Animation.RELATIVE_TO_PARENT, 1f, Animation.RELATIVE_TO_SELF, 0, // Animation.RELATIVE_TO_SELF, 0f); /** * 平移(上下) */ Animation translateAnimation3 = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, -0.1f); translateAnimation3.setDuration(100); translateAnimation3.setRepeatCount(10); translateAnimation3.setStartOffset(500); translateAnimation3.setFillAfter(true); /** * 平移(从左下到右上) */ Animation translateAnimation4 = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 1f, Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, -1f); translateAnimation4.setDuration(1000); translateAnimation4.setStartOffset(2000); //右下角开始缩放 // ScaleAnimation scale = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 1); //左下角开始缩放 ScaleAnimation scale = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1); scale.setDuration(500); scale.setFillAfter(true); animationSet.addAnimation(scale); animationSet.addAnimation(translateAnimation4); animationSet.addAnimation(translateAnimation3); // translateAnimation3.setInterpolator(new AccelerateInterpolator()); animationSet.setFillAfter(true); splash_iv2.startAnimation(animationSet);
Android 代码实现的动画
最新推荐文章于 2024-06-07 23:40:27 发布