我想实现的是,一个控件上面同事拥有两种或者两种以上的动画效果。比如说我给一个ImageView设置了一个移动的动画效果,但是我还想让这个控件在移动的同时进行旋转。这个该怎么做?跪求懂得大神指点
AnimationSet as;
Animation bs;
TranslateAnimation ta;
ScaleAnimation sa;
RotateAnimation ra;
AlphaAnimation aa;
ta=new TranslateAnimation(0f, 500, 0f, 550);
sa=new ScaleAnimation(1f, 0.5f, 1f, 0.5f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
ra=new RotateAnimation(0f, 1800f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
ta.setDuration(2000);
ta.setRepeatCount(-1);
sa.setDuration(2000);
sa.setRepeatCount(-1);
ra.setRepeatCount(-1);
ra.setDuration(2000);
bs=AnimationUtils.loadAnimation(this, R.layout.animation);
as.setDuration(2000);
as.setRepeatCount(-1);
as.addAnimation(sa);
as.addAnimation(ra);
as.addAnimation(ta);
然后用view.startAnimation(as)就行了,AnimationSet就是一系列的动作
android:duration="2000"
android:repeatCount="-1"
android:interpolator="@android:anim/bounce_interpolator">
android:fromXScale="1"
android:toXScale="0.5"
android:fromYScale="1"
android:toYScale="0.5"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:repeatCount="-1"
android:interpolator="@android:anim/bounce_interpolator" />
android:fromDegrees="0"
android:toDegrees="2160"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:repeatCount="-1"
android:interpolator="@android:anim/bounce_interpolator" />
android:fromXDelta="0"
android:toXDelta="-500"
android:fromYDelta="0"
android:toYDelta="550"
android:duration="2000"
android:repeatCount="-1"
android:interpolator="@android:anim/bounce_interpolator" />