1. Main code:
Statement:
Private View shareview;private Popupwindow pop;
In the OnCreate method:
introduced window profile Shareview = Layoutinflater.from (this). Inflate (r.layout.jyx_activity_share, NULL);//Create Popupwindow Object pop = New Popupwindow (Shareview, layoutparams.match_parent,layoutparams.wrap_content, false);//need to set this parameter, Click outside to disappear pop.setbackgrounddrawable (new colordrawable ());//Set the window to the outside window disappears pop.setoutsidetouchable (true); Pop.setanimationstyle (R.style.animationpreview);//Set this parameter to get focus, otherwise you cannot click Pop.setfocusable (TRUE); Pop.setondismisslistener (New Ondismisslistener () {@Overridepublic void Ondismiss () {SHARESDK.STOPSDK ( productactivity.this);});
In the onclick event: (one is a shared button, one is the Cancel button in the box)
Case R.id.share:if (Pop! = null &&!pop.isshowing ()) {pop.showatlocation (View.getrootview (), Gravity.bottom, 0, 0);} Break;case r.id.btn_cancel:if (Pop! = null && pop.isshowing ()) {Pop.dismiss ();} Break
Effect:
Android Popupwindow pop-up window (with common sharing interface as an example)