1. Set the Popupwindow background to 60% Transparent
window window = Activity.getwindow ();
Windowmanager.layoutparams LP = Window.getattributes ();
Lp.alpha = 0.6f;
Window.setattributes (LP);
Remember to hide the popupwindow when you need to recover
Windowmanager.layoutparams LP = Window.getattributes ();
lp.alpha = 1f;
window.setattributes (LP);
2. Problems with positioning
2.1 Get custom view's Wide height * * *
View.measure (Layoutparams.wrap_content, layoutparams.wrap_content);
int viewwidth = View.getmeasuredwidth ();
int viewheight = View.getmeasuredheight ();
2.2 The position of the Popupwindow relative Guideview can be calculated based on the width of the loaded view.
Popwindow.showasdropdown (Guideview, location[0], location[1]);
or position relative to the entire screen:
Popwindow.showatlocation (parent, gravity.center, 0, 0);
3. Do not add popwindow.setbackgrounddrawable (New bitmapdrawable ()); Popwondow does not respond to return key events and click Out-of-zone events.
4. After the Popupwindow appears, the default is that all operations are not valid except the home key. And you can manipulate the back.
interface. To lock the back of the interface, it's simple, just let Popupwindow be focusable.
Popupwindow.setfocusable (TRUE);
5. Get events outside of the click Area
popwindow.setfocusable (true);
popwindow.settouchable (true);
Popwindow.settouchinterceptor (New Ontouchlistener () {
@Override
Public boolean OnTouch (View V, motionevent event) {
if (popwindow.isshow ()) {
Show Popwindow
return true;
}
return false;
}
});
This article is from the "Sheep" blog, please make sure to keep this source http://5934497.blog.51cto.com/5924497/1617937
Use of Android Popupwindow