Basic use of Popupwindow

Source: Internet
Author: User

Reprint please indicate the source, thank you ~ ~

First of all, this is a tool-like blog, mainly to achieve popupwindow from the top or bottom or around the effect of the appearance. In order not to rewrite every time, so a method is taken out.

Private void Initpopuptwindow() {Layoutinflater layoutinflater = Layoutinflater.from ( This);//user_icon replace it with your own layoutView Popupwindow = layoutinflater.inflate (R.layout.user_icon,NULL); Mpopupwindow =NewPopupwindow (Popupwindow, layoutparams.match_parent, layoutparams.match_parent); Mpopupwindow.setoutsidetouchable (true); Mpopupwindow.setfocusable (true);//This property must be setMpopupwindow.setbackgrounddrawable (NewColordrawable (-000000));//This is the animation that sets the Popupwindow to appearMpopupwindow.setanimationstyle (R.style.anim_photo_select);//ll_root is the control you want to rely on, here is the layout of the control id,gravity is where you want to come out, here is the bottom. The next two bits are then offset by the X, y direction. Mpopupwindow.showatlocation (Ll_root, Gravity.bottom,0,0); }

R.style.anim_photo_select is the animation that appears in Popupwindow, which is written in the Styles.xml file:

name="anim_photo_select">        <itemname="android:windowEnterAnimation">@anim/photo_pop_in</item>        <itemname="android:windowExitAnimation">@anim/photo_pop_out</item></style>

Then @anim/photo_pop_in and out are animated files that are placed in the Anim folder.
In

<?xml version= "1.0" encoding= "Utf-8"?><set xmlns:android="Http://schemas.android.com/apk/res/android" >    <translate android:fromydelta="100%p" android:toydelta="0" android:duration="@android: Integer/config_mediumanimtime"/>                <Alpha android:fromalpha="0.5" android:toalpha="1.0"  Android:duration="@android: Integer/config_mediumanimtime" />            </Set>

Out

<?xml version= "1.0" encoding= "Utf-8"?><set xmlns:android="Http://schemas.android.com/apk/res/android" >     <translate android:fromydelta="0%p" android:toydelta="100%p" android:duration="@android: Integer/config_mediumanimtime"/>            <Alpha android:fromalpha="1.0" android:toalpha="0.5" android:duration="@android: Integer/config_mediumanimtime" />        </Set>

effect, because did not do the adaptation, so make a look at it, hahaha:

Basic use of 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.