1, define the animation of Popupwindow appearing and disappearing under Res/anim
① The animated popupwindow_show.xml that appears
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Alphaxmlns:android= "Http://schemas.android.com/apk/res/android"3 android:duration= "+"4 Android:fromalpha= "0.0"5 Android:fillafter= "true"6 Android:interpolator= "@android: Anim/accelerate_decelerate_interpolator"7 Android:toalpha= "1.0" >8 </Alpha>
② Disappearing Animation Popupwindow_dismiss.xml
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Alphaxmlns:android= "Http://schemas.android.com/apk/res/android"3 android:duration= "+"4 Android:fromalpha= "1.0"5 Android:fillafter= "true"6 Android:interpolator= "@android: Anim/accelerate_decelerate_interpolator"7 Android:toalpha= "0.0" >9 </Alpha>
2,popupwindow animation is done by means of Setanimationstyle (R.style.popupwindow_anim_style);
So add in the Styles.xml under Res/values
1 <stylename= "Popupwindow_anim_style">2 <Itemname= "Android:windowenteranimation">@anim/popupwindow_show</Item>3 <Itemname= "Android:windowexitanimation">@anim/popupwindow_dismiss</Item>4 </style>
3, apply to code
Mpopupwindow.setanimationstyle (R.style.popupwindow_anim_style); Mpopupwindow.update ();
Android UI (inherited control)--popupwindow animating