2012-10-03 63 views
3

我檢出了API代碼附帶的過渡動畫,並且發現活動1下沉的動畫zoom_enter和zoom_exit顯示活動2.我需要其他方式。我需要活動2從內部縮小和頂部。 (我希望你能得到我)。這種類型的動畫在iphone屏幕轉換上是一樣的。縮小兩個活動之間的過渡動​​畫

下面的代碼是我所具有的效果,我不需要。 這裏是zoom_enter.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:interpolator="@android:anim/decelerate_interpolator"> 
    <scale android:fromXScale="2.0" android:toXScale="1.0" 
     android:fromYScale="2.0" android:toYScale="1.0" 
     android:pivotX="50%p" android:pivotY="50%p" 
     android:duration="@android:integer/config_mediumAnimTime" /> 
</set> 

的代碼,這裏是zoom_exit.xml代碼

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:interpolator="@android:anim/decelerate_interpolator" 
    android:zAdjustment="top"> 
    <scale android:fromXScale="1.0" android:toXScale=".5" 
     android:fromYScale="1.0" android:toYScale=".5" 
     android:pivotX="50%p" android:pivotY="50%p" 
     android:duration="@android:integer/config_mediumAnimTime" /> 
    <alpha android:fromAlpha="1.0" android:toAlpha="0" 
     android:duration="@android:integer/config_mediumAnimTime"/> 
</set> 

然後之後startActivity我叫下面的方法:

overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); 

燦任何人都可以提出如何對上述文件進行更改以解釋屏幕過渡?

+0

您是否嘗試顛倒R.anim.zoom_enter並退出?什麼是錯的,你想要改進什麼? –

+0

當我反轉參數它仍然是一樣的。我得到了和以前一樣的效果,但有一些小故障。這就是我的意思。看看當一個圖標被點擊的時候,第二個活動彈出來.http://www.youtube.com/watch?feature = endscreen&NR = 1&v = eHm9MwjiwQA – Hussein

+0

@jasper,只需在該參數中加0即可。 –

回答

10

在zoom_enter.xml中嘗試此操作,並從zoom_exit.xml中刪除動畫。你會看到更好的效果。

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:interpolator="@android:anim/decelerate_interpolator"> 
    <scale android:fromXScale="0.0" android:toXScale="1.0" 
     android:fromYScale="0.0" android:toYScale="1.0" 
     android:pivotX="50%p" android:pivotY="50%p" 
     android:duration="@android:integer/config_mediumAnimTime" /> 
</set> 

希望這會有所幫助。

+1

需要做些什麼:「從zoom_exit.xml中刪除動畫」? – Jasper

2

overridePendingTransition(zoom_enter_new,zoom_exit_actual);

第一個參數是傳入的活動(所以新) 二參數是爲即將離任的活動(實際)

所以,如果你想在那裏似乎相同視頻效果 實際活動隱藏瞬間比第二參數需要設置爲0(意味着沒有動畫)

overridePendingTransition(zoom_enter_new,0);

和用於製備新的活動zoomin像視頻,這是動畫XML資源解釋(zoom_enter_new.xml在res /動畫/ DIR)

<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:interpolator="@android:anim/accelerate_decelerate_interpolator"> 
    <!--scale view fromX fromY are the starting point (.5 is 50% of scale,)--> 
    <!--scale view toX and toY are the final state (1 is 100%)--> 
    <!--pivot is the center of animation, so in your case the zoomin on the video is from the exact center (50% pivot x, 50% pivot Y)--> 
    <scale android:fromXScale=".5" android:toXScale="1" 
     android:fromYScale=".5" android:toYScale="1" 
     android:pivotX="50%p" android:pivotY="50%p" 
     android:duration="@android:integer/config_longAnimTime" /> 

    <!-- alpha animation is made at the same time of scale animation, and for me make a better and smooth result, alpha 0 is full trasparent, 1 is the normal state. The final alpha state of the activity after this animation is 1, so pay attention toAlpha must be 1 if you don't want glitch--> 
    <alpha android:fromAlpha="0.5" android:toAlpha="1" 
     android:duration="@android:integer/config_longAnimTime"/> 
</set> 

overridePendingTransition(R.anim.zoom_enter_new,0);

託比亞