Android dialog box pop-up animation

Source: Internet
Author: User
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  >   

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.