2011-02-14 27 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