First, you define the animation file that displays the effect:
- <? XML version= "1.0" encoding="Utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android">
- <translate
- android:fromxdelta="0"
- android:toxdelta="0"
- android:fromydelta="
- android:toydelta="0"
- android:duration=" /> "
- </Set>
Then define the animation file for the Vanishing effect:
- <? XML version= "1.0" encoding="Utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android">
- <translate
- android:fromxdelta="0"
- android:toxdelta="0"
- android:fromydelta="0"
- android:toydelta="
- android:duration=" /> "
- </Set>
The animated display of Popupwindow is set by the Setanimationstyle (int id) method, where ID is the ID of a style, so we want to set an animation style in the Styles.xml file:
- <style name="Popwin_anim_style">
- <item name="android:windowenteranimation"> @anim/menushow</Item>
- <item name="android:windowexitanimation"> @anim/menuhide</Item>
- </style>
Then set the Popupwindow in the program as:
- Popupwindow pop = new Popupwindow (view, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT );
- Pop.setanimationstyle (R.style.popwin_anim_style);
Android Animation for Popupwindow