1. Above the control:
Private voidshowPopUp (View v) {linearlayout layout=NewLinearLayout ( This); Layout.setbackgroundcolor (Color.gray); TextView TV=NewTextView ( This); Tv.setlayoutparams (Newlayoutparams (layoutparams.wrap_content, layoutparams.wrap_content)); Tv.settext ("I ' m a pop-----------------------------!"); Tv.settextcolor (Color.White); Layout.addview (TV); Popupwindow=NewPopupwindow (Layout, -, -); Popupwindow.setfocusable (true); Popupwindow.setoutsidetouchable (true); Popupwindow.setbackgrounddrawable (Newbitmapdrawable ()); int[] location =New int[2]; V.getlocationonscreen (location); Popupwindow.showatlocation (V, gravity.no_gravity, location[0], location[1]-popupwindow.getheight ()); }
displaying in the other direction of the control simply modifies the last line of code, such as:
Popupwindow.showasdropdown (v);
At the bottom, other methods
int New int [2]; 0, location[1]+v.getheight ());
3. Left:
Popupwindow.showatlocation (V, gravity.no_gravity, location[0]-popupwindow.getwidth (), location[1 ]);
4. Right:
Popupwindow.showatlocation (V, gravity.no_gravity, location[0]+v.getwidth (), location[1]);
Android Popupwindow location display