Setanimationstyle implementation of Popwindow display vanishing animation effect

Source: Internet
Author: User

abstract Popwindow animation effects by setanimationstyle (int animationstyle) function android:windowenteranimation to enter window animation Android : Windowexitanimation indicates that the window exits the animation in the Res/values/style.xml code:? xml version= "1.0" encoding= "Utf-8"? Resources style

Popwindow animating effects with setanimationstyle (int animationstyle) function
Android:windowenteranimation to enter the window animation
Android:windowexitanimation indicates that the window exits the animation

In the Res/values/style.xml code:

[HTML]View Plaincopy
  1. <? XML version= "1.0"encoding= "Utf-8"?>
  2. <resources>
  3. <style name= "popupanimation"parent= "android:animation"mce_bogus="1">
  4. <item name="android:windowenteranimation"> @anim/popup_enter</Item>
  5. <item name="android:windowexitanimation"> @anim/popup_exit</Item >
  6. </style>
  7. </Resources>

In the Res/anim/popup_enter.xml declaration required to enter the animation

[HTML]View Plaincopy
  1. <? XML version= "1.0"encoding= "Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">
  3. <scale android:fromxscale= "0.6"Android: toxscale="1.0"
  4. android:fromyscale= "0.6"Android: toyscale= "1.0"android:p ivotx="50% "
  5. android:pivoty= "50%"android:d uration="$"/>
  6. <Alpha android:interpolator="@android: Anim/decelerate_interpolator"
  7. android:fromalpha= "0.0"Android: toalpha= "1.0"android:d uration="$"/>
  8. </Set>


Exit animation required in Res/anim/popup_exit.xml declaration

[HTML]View Plaincopy
  1. <? XML version= "1.0"encoding= "Utf-8"?>
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">
  3. < scale
  4. android:fromxscale="1.0"
  5. android:toxscale="0.5"
  6. android:fromyscale="1.0"
  7. android:toyscale="0.5"
  8. android:pivotx="50%"
  9. android:pivoty="50%"
  10. android:duration="/> "
  11. <Alpha
  12. android:interpolator="@android: Anim/accelerate_interpolator"
  13. android:fromalpha="1.0"
  14. android:toalpha="0.0"
  15. android:duration="/> "
  16. </Set>


Setting the location and animation of Popwindow

Popupwindow.setanimationstyle (r.style.popupanimation);
Popupwindow.showatlocation (Findviewbyid (r.id.parent), gravity.center| Gravity.center, 0, 0);
Popupwindow.update ();

Call Popupwindow.dismiss (); statement. Popwindow disappears, auto-call disappears animation popup_exit.xml

http://blog.csdn.net/heng615975867/article/details/8893655

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.