我在我当前的项目中使用它,它基本上非常简单。你在你的styles.xml中定义一个新的动画风格,像这样:
<!-- just defines top layer "Animation" -->
<style name="Animation" />
<!-- the animations must have been defined in your "anim" folder, of course -->
<style name="Animation.MyAwesomeAnimation" parent="android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/myawesomeanimation_enter</item>
<item name="android:activityOpenExitAnimation">@anim/hold_long</item>
<item name="android:activityCloseEnterAnimation">@anim/hold_long</item>
<item name="android:activityCloseExitAnimation">@anim/myawesomeanimation_exit</item>
</style>
然后在主题 (themes.xml) 中设置此样式:
<style name="Theme.MyAwesomeTheme" parent="Theme.Default">
<item name="android:windowAnimationStyle">@style/Animation.MyAwesomeAnimation</item>
</style>
然后您可以简单地将这些主题设置为您喜欢的 AndroidManifest.xml 中的每个活动:
<activity
android:name=".MyAwesomeActivity"
android:theme="@style/Theme.MyAwesomeTheme" />
现在,我祝您在活动动画中玩得开心!:-D