Android Animation for Popupwindow

Source: Internet
Author: User

First, you define the animation file that displays the effect:
  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">
  3. <translate
  4. android:fromxdelta="0"
  5. android:toxdelta="0"
  6. android:fromydelta="
  7. android:toydelta="0"
  8. android:duration=" /> "
  9. </Set>

Then define the animation file for the Vanishing effect:
  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">
  3. <translate
  4. android:fromxdelta="0"
  5. android:toxdelta="0"
  6. android:fromydelta="0"
  7. android:toydelta="
  8. android:duration=" /> "
  9. </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:

  1. <style name="Popwin_anim_style">
  2. <item name="android:windowenteranimation"> @anim/menushow</Item>
  3. <item name="android:windowexitanimation"> @anim/menuhide</Item>
  4. </style>

Then set the Popupwindow in the program as:

    1. Popupwindow pop = new Popupwindow (view, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT  );
    2. Pop.setanimationstyle (R.style.popwin_anim_style);

Android Animation for Popupwindow

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.