質問

I'm using fade_in and fade_out animations avaible android.R.anim.fade_in(fade_out). Basically I can change duration of animation but no matter if it's 0,5 or 2 seconds animation is still not smooth. Is there any way to make a fade in/out animation smoother? Thanks a lot!

Code:

imageSwitcher = (ImageSwitcher) findViewById(R.id.imageswitcher);

    slide_in_left = AnimationUtils.loadAnimation(this, R.anim.fade);
    slide_out_right = AnimationUtils.loadAnimation(this, R.anim.fade_out);

    imageSwitcher.setInAnimation(slide_in_left);
    imageSwitcher.setOutAnimation(slide_out_right);

*XML fade_out:*

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha
        android:duration="1500"
        android:fromAlpha="1.0"
        android:toAlpha="0.0"
        android:interpolator="@android:anim/accelerate_interpolator" />
</set>
役に立ちましたか?

解決

There are several things you can do to improve the Animation. First, enable hardware acceleration in your Android Manfiest, by adding the application attribute:

android:hardwareAccelerated="true"

Next, try some different *interpolator*s. You may find @android:anim/linear to be smoother.

Finally, if this does not work, you can always do this programmatically use Property Animations (you can use NineOldAndroids for older API versions).

他のヒント

What worked for me is also minimizing my app's background image's file size.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top