Button. setonclicklistener ( New Onclicklistener () {@ override Public Void Onclick (view arg0 ){ // Todo auto-generated method stub Alertdialog dialog = New Alertdialog. Builder (testandroid1activity. This ). Settitle ( "Title"). setmessage ("message" ). Create (); window =Dialog. getwindow (); window. setgravity (gravity. Bottom ); // You can set the dialog display position here. Window. setwindowanimations (R. style. mystyle ); // Add an animation Dialog. Show ();}});
Styles. xml
<? XML version = "1.0" encoding = "UTF-8" ?> < Resources > < Style Name = "Mystyle" Parent = "Android: Animation" > < Item Name = "@ Android: windowenteranimation" > @ Anim/dialog_enter </ Item > // Enter the animation < Item Name = "@ Android: javaswexitanimation" > @ Anim/dialog_exit </ Item > // Animation at exit </ Style > Resources>
Res/anim/dialog_enter.xml
XML version = "1.0" encoding = "UTF-8" ?> set xmlns: Android =" http://schemas.android.com/apk/res/android " > translate Android: fromydelta = "100% P" % P indicates the Android: Duration =" 600 " /> set >
Located in RES/anim/dialog_exit.xml <? XML version = "1.0" encoding = "UTF-8" ?> < Set Xmlns: Android = "Http://schemas.android.com/apk/res/android" > < Translate Android: toydelta = "100% P" Android: Duration = "600" // Duration /> </ Set >