Implemented in projects
Android Popupwindow appears above or below the control
The main code is as follows
View view = Minflater.inflate (R.layout.layout_popupwindow, NULL);
Popupwindowlayout popupwindowlayout = (popupwindowlayout) View.findviewbyid (R.id.llayout_popupwindow);
Popupwindowlayout.initviews (Mcontext, titles, false);
Final Popupwindow Popupwindow = new Popupwindow (view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
View.measure (measurespec.unspecified, measurespec.unspecified);
int popupwidth = View.getmeasuredwidth ();
int popupheight = View.getmeasuredheight ();
int[] location = new INT[2];
Allow click outside to disappear
Popupwindow.setbackgrounddrawable (New bitmapdrawable ());
Popupwindow.setoutsidetouchable (TRUE);
Popupwindow.setfocusable (TRUE);
Get location
V.getlocationonscreen (location);
Popupwindow.setanimationstyle (R.style.mypopwindow_anim_style);
Popupwindow.showatlocation (V, gravity.no_gravity, (location[0] + v.getwidth ()/2)-POPUPWIDTH/2, location[1]-popupHe ight);
Photo and demo Download link Download complete demo click Open link
Android Popupwindow appears above or below the control