5

I am trying to create a moving ball animation in my app everything is working fine, ball moved as i want but it is not smooth. I tried everything to make it smooth but no luck every time i failed.

here is my xml code:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="true" >

    <translate
        android:duration="3000"
        android:fromXDelta="-1%p"
        android:fromYDelta="-87%p"
        android:toXDelta="1%p"
        android:toYDelta="-40%p" />

    <translate
        android:duration="3000"
        android:fromXDelta="2%p"
        android:fromYDelta="0%p"
        android:startOffset="2200"
        android:toXDelta="0%p"
        android:toYDelta="42%p" />

    <translate
        android:duration="4000"
        android:fromXDelta="0%p"
        android:fromYDelta="42%p"
        android:startOffset="4500"
        android:toXDelta="-5%p"
        android:toYDelta="0%p" />

    <translate
        android:duration="4000"
        android:fromXDelta="0%p"
        android:fromYDelta="0%p"
        android:startOffset="5500"
        android:toXDelta="4%p"
        android:toYDelta="-47%p" />


</set>

and here is my java code:

ImageView image = (ImageView)findViewById(R.id.imageView1);
Animation anim = AnimationUtils.loadAnimation(this, R.drawable.moveing_ball_anim); 
image.startAnimation(anim);

I move image in this shape.

VipiN Negi
  • 2,994
  • 3
  • 24
  • 47
Pari
  • 1,705
  • 4
  • 18
  • 19

1 Answers1

2

You need to try to use LinearInterpolator instead AccelerateInterpolator.

Go through this link, and try to implement it. You will get your solution. Link

Community
  • 1
  • 1
Java
  • 2,451
  • 10
  • 48
  • 85