开发者

AnimationSet issue in android

I'm using AnimationSet to perform a sequence of TranslateAnimations.

    icon = (ImageView)findViewById(R.id.icon);

    AnimationSet animation开发者_如何学运维Set = 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?


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..


Try using the higher duration for animations (>= 1500).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜