在Activity的setContentView下面写入动画代码
this.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); this.getWindow().setWindowAnimations(R.style.photo_detail_dialog_style); // 添加动画
在styles中写入
<style name="photo_detail_dialog_style" parent="android:Animation"> <item name="@android:windowEnterAnimation">@anim/dialog_enter_from_bottom</item> <item name="@android:windowExitAnimation">@anim/dialog_exit_from_top</item> </style>
在res下创建anim文件夹
创建dialog_enter_from_bottom
<set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:fromYDelta="100%p" /> </set>
创建dialog_exit_from_top
<set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="150" android:toYDelta="100%p" /> </set>
就可以了