Fly In Animation for a GridView

前端 未结 1 1530
慢半拍i
慢半拍i 2021-02-03 16:21

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 f

相关标签:
1条回答
  • 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.

    0 讨论(0)
提交回复
热议问题