Reputation: 569
I'm using AnimationSet to perform a sequence of 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);
My problem is that the animation is very jerky. The first animation occurs very abruptly, then the second one starts. How can I make this smooth & even?
Upvotes: 4
Views: 5662
Reputation: 33248
create xml file for animation and try this
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>
u must change value whatever u want..
Upvotes: 5