2011-02-14 55 views
3

我有一个gridview,我试图实现对其中的图像有效的飞行。这与您加载图库3D和图像文件夹“放入”时看到的效果非常相似。 我已经围绕主题Google搜索,并认为我需要使用ViewAnimator并产生通过动画:http://developer.android.com/reference/android/widget/ViewAnimator.html#setInAnimation(android.view.animation.AnimationFly In Animation for GridView

但是,我不知道,并就如何实现这一目标不得以任何帮助将是非常欢迎!

问候

马克

回答

10

你要飞的动画每格,或整个看法?

对于整个视图,使用:

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

然后在文件flyin.xml像这样指定动画:

<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> 

把该文件在您的RES /动画目录。

+0

这是整个视图。谢谢,我从来没有想过它会需要这么几行代码! – Mark 2011-02-14 12:17:19