过渡动画与AnimationSet活动之间

过渡动画与AnimationSet活动之间

本文介绍了过渡动画与AnimationSet活动之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在overridePendingTransition(INT,INT)方法提供了一种使用XML的动画资源活动之间的动画。

The overridePendingTransition(int, int) method provides a way to animate between activities using the animation XML resources.

但是,如果我们需要一个AnimationSet(一堆动画甚至可能包括一个Java动画太)指定为它的参数?

But what if We need to assign an AnimationSet (a bunch of animations that might even include a java animation too) as its arguments?

在换句话说,我们如何可以申请AnimationSets的活动之间的转换?

In other word how can we apply AnimationSets for transitions between activities?

推荐答案

我已成功地实现通过使用主题在我的应用程序。

I have managed to achieve that by using themes in my app.

具体由一个主题改变这种风格:

Specifically by changing this style in a theme:

<item name="android:windowAnimationStyle">@android:style/Animation.Activity</item>

和压倒一切的作风Animation.Activity:

and overriding style Animation.Activity:

<style name="Animation.Activity">
        <item name="activityOpenEnterAnimation">@anim/activity_open_enter</item>
        <item name="activityOpenExitAnimation">@anim/activity_open_exit</item>
        <item name="activityCloseEnterAnimation">@anim/activity_close_enter</item>
        <item name="activityCloseExitAnimation">@anim/activity_close_exit</item>
        <item name="taskOpenEnterAnimation">@anim/task_open_enter</item>
        <item name="taskOpenExitAnimation">@anim/task_open_exit</item>
        <item name="taskCloseEnterAnimation">@anim/task_close_enter</item>
        <item name="taskCloseExitAnimation">@anim/task_close_exit</item>
        <item name="taskToFrontEnterAnimation">@anim/task_open_enter</item>
        <item name="taskToFrontExitAnimation">@anim/task_open_exit</item>
        <item name="taskToBackEnterAnimation">@anim/task_close_enter</item>
        <item name="taskToBackExitAnimation">@anim/task_close_exit</item>
        <item name="wallpaperOpenEnterAnimation">@anim/wallpaper_open_enter</item>
        <item name="wallpaperOpenExitAnimation">@anim/wallpaper_open_exit</item>
        <item name="wallpaperCloseEnterAnimation">@anim/wallpaper_close_enter</item>
        <item name="wallpaperCloseExitAnimation">@anim/wallpaper_close_exit</item>
        <item name="wallpaperIntraOpenEnterAnimation">@anim/wallpaper_intra_open_enter</item>
        <item name="wallpaperIntraOpenExitAnimation">@anim/wallpaper_intra_open_exit</item>
        <item name="wallpaperIntraCloseEnterAnimation">@anim/wallpaper_intra_close_enter</item>
        <item name="wallpaperIntraCloseExitAnimation">@anim/wallpaper_intra_close_exit</item>
    </style>

您可以用XML定义你的动画集,并引用它们的这种风格。

You can define your animation sets in XML and reference them in this style.

这篇关于过渡动画与AnimationSet活动之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 09:35