Search code examples
androidanimationhardware-acceleration

Android - sluggish animation when using ViewAnimator, is it possible to use hardware acceleration?


I have the following code, that adds views to ViewAnimator

View step1 = View.inflate(activity, R.layout.step_1, null);
View step2 = View.inflate(activity, R.layout.step_2, null);
viewAnimator.addView(step1);
viewAnimator.addView(step2);
viewAnimator.setInAnimation(activity, R.anim.slide_in);
viewAnimator.setOutAnimation(activity, R.anim.slide_out);

and the following xmls

slide_in:

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:shareInterpolator="false">
    <translate
            android:fromXDelta="100%" android:toXDelta="0%"
            android:fromYDelta="0%" android:toYDelta="0%"
            android:duration="700" />
</set>

slide_out:

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:shareInterpolator="false">
    <translate android:fromXDelta="0%" android:toXDelta="-100%"
               android:fromYDelta="0%" android:toYDelta="0%"
               android:duration="700"/>
</set>

Now, all works fine, however the performance of the animation looks sluggish and slow comparing to the native animations on my phone (Samsung galaxy S).

I use API level 8, can I use any hardware acceleration, or should I change my approach for the whole concept?

Thanks a bundle


Solution

  • <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/> was missing from my manifest file, once added the animation is super smooth.