我正在使用AnimationSet来执行TranslateAnimations序列。
icon = (ImageView)findViewById(R.id.icon);
AnimationSet animationSet = new AnimationSet(true);
animationSet.setInterpolator(new AccelerateInterpolator());
TranslateAnimation slide1 = new TranslateAnimation(0, 50, 0, 100);
slide1.setStartOffset(0);
slide1.setDuration(800);
animationSet.addAnimation(slide1);
TranslateAnimation slide2 = new TranslateAnimation(50, 100, 100, -100);
slide2.setStartOffset(1000);
slide2.setDuration(800);
animationSet.addAnimation(slide2);
....
animationSet.setFillAfter(true);
icon.startAnimation(animationSet);
我的问题是动画非常生涩。第一个动画突然发生,然后第二个动画开始。我怎样才能使这个顺利&甚至?
答案 0 :(得分:5)
为动画创建xml文件并尝试此
AnimationSet animSet = new AnimationSet(false);
Animation AnimFirst = AnimationUtils.loadAnimation(act, R.anim.first);
Animation rAnimSecond = AnimationUtils.loadAnimation(act, R.anim.second);
animSet.addAnimation(AnimFirst);
animSet.addAnimation(AnimSecond);
animSet.setInterpolator(new AccelerateDecelerateInterpolator());
icon.clearAnimation();
animSet.setFillAfter(true);
icon.startAnimation(animSet);
animFirst.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="100%" android:toXDelta="0"
android:duration="2000" android:fillAfter="true" />
</set>
你必须随意改变价值..
答案 1 :(得分:0)
尝试使用较高的动画持续时间(&gt; = 1500)。