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)