2011-12-20 33 views
11

Để tìm kiếm trên mạng, tôi thấy rằng có lớp ViewFlipper cung cấp hoạt ảnh xem Lật giữa hai chế độ xem/Nhưng đối với hoạt động đó phải ở cùng một Hoạt động. Tôi cũng biết rằng hoạt ảnh Flip không được hỗ trợ cho thay đổi hoạt động. hiện tại, Android chỉ hỗ trợ hoạt ảnh 2d trong khi thay đổi hoạt động.Android: Flip Animation sử dụng XML cho hoạt ảnh trong android

Tôi muốn tạo hiệu ứng tương tự để thay đổi hoạt động.

Vì vậy, có bất kỳ hình ảnh tương tự như xml nào có hiệu lực giống như chế độ xem FLIP vì vậy tôi cung cấp thay đổi hoạt động của mình và nhận hiệu ứng Flip như vậy cho thay đổi Hoạt động.

Vui lòng cung cấp cho tôi một số xml cho hoạt ảnh cung cấp hoạt ảnh Flip loại hoạt động để thay đổi hoạt động.

Cảm ơn.

Trả lời

43

Hãy thử điều này

overridePendingTransition(R.anim.grow_from_middle,R.anim.shrink_to_middle); 

grow_from_middle.xml

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <scale 
     android:interpolator="@android:anim/linear_interpolator" 
     android:fromXScale="0.0" 
     android:toXScale="1.0" 
     android:fromYScale="0.7" 
     android:toYScale="1.0" 
     android:fillAfter="false" 
     android:startOffset="200" 
     android:duration="200" /> 
    <translate 
     android:fromXDelta="50%" 
     android:toXDelta="0" 
     android:startOffset="200" 
     android:duration="200"/> 
</set> 

shrink_to_middle.xml

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <scale 
     android:interpolator="@android:anim/linear_interpolator" 
     android:fromXScale="1.0" 
     android:toXScale="0.0" 
     android:fromYScale="1.0" 
     android:toYScale="0.7" 
     android:fillAfter="false" 
     android:duration="200" /> 
    <translate 
     android:fromXDelta="0" 
     android:toXDelta="50%" 
     android:duration="200"/> 
</set> 
+0

Cảm ơn blessenm cho câu trả lời. Hãy để tôi kiểm tra nó. –

+0

nơi tôi phải viết dòng này: ghi đèPendingTransition (R.anim.grow_from_middle, R.anim.shrink_to_middle); –

+0

Tôi đã dán nó sau khi bắt đầu hoạt động nhưng nó nói với tôi để crete crete có cùng tên. –