Popwindow Custom Animations (NEXUS5 does not support pending resolution)

Source: Internet
Author: User

If you encounter a problem, record it first.

Popwindow Custom Animations

Importandroid.app.Activity;Importandroid.graphics.drawable.BitmapDrawable;ImportAndroid.os.Build;ImportAndroid.os.Bundle;ImportAndroid.util.DisplayMetrics;Importandroid.view.Gravity;ImportAndroid.view.LayoutInflater;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.view.ViewGroup.LayoutParams;ImportAndroid.widget.Button;ImportAndroid.widget.PopupWindow; Public classActivitymainextendsActivity {Private intScreenWidth; Private intScreenheigh; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.main); System.out.println ("Xirtam" +Build.VERSION.SDK); System.out.println ("Xirtam" +Build.VERSION.SDK_INT); {//Get screen width heightDisplaymetrics DM =NewDisplaymetrics ();            Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); ScreenWidth=Dm.widthpixels; Screenheigh=Dm.heightpixels; } layoutinflater Inflater= Layoutinflater.from ( This); //Introducing a window configuration fileView view = Inflater.inflate (R.layout.main2,NULL); //Create a Popupwindow object        FinalPopupwindow pop =NewPopupwindow (view, Layoutparams.match_parent, Layoutparams.wrap_content,false); Button btn=(Button) Findviewbyid (R.ID.BTN); //need to set this parameter, click outside to disappearPop.setbackgrounddrawable (Newbitmapdrawable ()); //Set Click Window outside window disappearsPop.setoutsidetouchable (true); //set this parameter to get focus, otherwise you cannot clickPop.setfocusable (true); Btn.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {if(Pop.isshowing ()) {//hidden window, if set to click outside the window hours that do not need this way to hidePop.dismiss (); } Else {                    //Display windowPop.setanimationstyle (r.style.popupanimation); Pop.showatlocation (V, gravity.no_gravity,0, Screenheigh);//Pop.showasdropdown (v);pop.update ();    }            }        }); }}

Layout/main1.xml

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"android:orientation= "vertical" >    <ButtonAndroid:id= "@+id/btn"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "point I am a puppy" /></LinearLayout>

Layout/main2.xml

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"android:orientation= "vertical" >    <ButtonAndroid:id= "@+id/a"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:text= "Hello puppy" /></LinearLayout>

Values/styles.xml

<stylename= "Popupanimation"Mce_bogus= "1"Parent= "Android:animation">        <Itemname= "Android:windowenteranimation">@anim/enter</Item>        <Itemname= "Android:windowexitanimation">@anim/exit</Item>    </style>

Anim/enter.xml

<? XML version= "1.0" encoding= "Utf-8" ?> <  xmlns:android= "http://schemas.android.com/apk/res/android"    android:duration  = "3500"    android:fromydelta= "100%"    Android:toydelta = "1%" > </ Translate >

Anim/exit.xml

<? XML version= "1.0" encoding= "Utf-8" ?> <  xmlns:android= "http://schemas.android.com/apk/res/android"    android:duration  = "3500"    android:fromydelta= "1%"    android:toydelta  = "100%"></translate>

The problem is that the showatlocation is not responding on the NEXUS5, and no other models have found this problem.

Popwindow Custom Animation (NEXUS5 does not support pending resolution)

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.