2016-10-01 128 views

回答

0

你必須設計在style.xml過渡

<style name="BaseAppTheme" parent="android:Theme.Material"> 
    <!-- enable window content transitions --> 
    <item name="android:windowActivityTransitions">true</item> 

    <!-- specify enter and exit transitions --> 
    <item name="android:windowEnterTransition">@transition/explode</item> 
    <item name="android:windowExitTransition">@transition/explode</item> 

    <!-- specify shared element transitions --> 
    <item name="android:windowSharedElementEnterTransition"> 
    @transition/change_image_transform</item> 
    <item name="android:windowSharedElementExitTransition"> 
    @transition/change_image_transform</item> 
</style> 

然後使用Window.requestFeature()方法調用相同的代碼。

// inside your activity (if you did not enable transitions in your theme) 
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); 

// set an exit transition 
getWindow().setExitTransition(new Explode()); 

閱讀下面的文檔,以得到一個想法 https://developer.android.com/training/material/animations.html#Transitions