Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving animation not smooth in android

Tags:

java

android

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.

like image 296
Pari Avatar asked Nov 05 '22 02:11

Pari


1 Answers

You need to try to use LinearInterpolator instead AccelerateInterpolator.

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

like image 186
Java Avatar answered Nov 09 '22 12:11

Java