First, define the motion tween in Values/anim
Popshow_anim.xml fade-in from bottom to top
xml version= "1.0" encoding =" Utf-8 "
<set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="+" Android:fromydelta="100%p" Android:toydelta="0" /> <Alpha android:duration="+" Android:fromalpha="0.0" Android:toalpha="1.0" /> </Set>
Pophidden_anim.xml fade from top to bottom
xml version= "1.0" encoding =" Utf-8 "
<set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="+" Android:fromydelta="0" Android:toydelta="50%p" /> <Alpha android:duration="+" Android:fromalpha="1.0" Android:toalpha="0.0" /> </Set>
then, define thestyle in the values/style
<style name = "Mypopwindow_anim_style" >
<item name="android:windowenteranimation"> /c5> @anim/popshow_anim</Item> <!--Specifies the animated XML that is displayed-- <item name="android:windowexitanimation"> @anim/pophidden_anim</Item> <!--Specify vanishing animation XML-- </style>
Finally, reference the animation style in your code
View view = Layoutinflater. from( This). Inflate (r.layout.Popwindowlayout, null);
Popupwindow Mpopupwindow = new popupwindow (view, Windowmanager.layoutparams. Match_parent, Windowmanager.layoutparams. wrap_content); mpopupwindow.setfocusable (true); mpopupwindow.setoutsidetouchable (true); mpopupwindow.setbackgrounddrawable (new colordrawable (0XCC00CC00)); //Set Popwindow display and fade animations Mpopupwindow.setanimationstyle (r.style. Mypopwindow_anim_style); mpopupwindow.showatlocation (mainactivity. this. Findviewbyid (r.id. Start), Gravity. BOTTOM, 0, 0);
From for notes (Wiz)
Popupwindow animation when pop-up windows