Mark
Mark

Reputation: 33

Fly In Animation for a GridView

I have a gridview, and I am trying to achieve a fly in effect on the images within it. This would be very similar to the effect seen when you load up gallery 3D and your image folders "drop in". I have googled around the subject, and think I need to use a ViewAnimator and generate the animation through that: http://developer.android.com/reference/android/widget/ViewAnimator.html#setInAnimation(android.view.animation.Animation)

However, I am not sure and any help on how to achieve this whatsoever would be very welcome!

Regards

Mark

Upvotes: 3

Views: 8144

Answers (1)

DKIT
DKIT

Reputation: 3481

Do you want the fly-in animation per grid, or for the entire view?

For the entire view, use this:

        Animation anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.flyin);
        findViewById(R.id.YourViewId).setAnimation(anim);
        anim.start();

Then specify your animation in a file flyin.xml like this:

<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="true">
    <scale android:interpolator="@android:anim/decelerate_interpolator"
           android:fromXScale="1.0" android:toXScale="0.0" 
           android:fromYScale="1.0" android:toYScale="0.0"
           android:pivotX="50%" android:pivotY="50%"
           android:fillAfter="false" android:duration="250"/>
</set>

Put that file in your res/anim-directory.

Upvotes: 10

Related Questions