dialog、activity等进入、退出动画实现

来源:互联网 发布:mac不能给iphone充电 编辑:程序博客网 时间:2024/05/21 19:10

无论是dialog还是activity,都是附着在window上的,因此,可以借用window的相关属性实现进入退出动画。
以dialog为例:

dialog.getWindow().getAttributes().windowAnimations = R.style.edit_dialog_style;

R.style.edit_dialog_style

<style name="edit_dialog_style" parent="android:Animation">        <item name="android:windowEnterAnimation">@anim/edit_label_enter_anim</item>        <item name="android:windowExitAnimation">@anim/edit_label_exit_anim</item>    </style>

animation

<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"     android:duration="500">    <translate        android:fromYDelta="100%"        android:toYDelta="0%"/></set>
0 0