Popupwindow animation when pop-up windows

Source: Internet
Author: User


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

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.