public class Testpopupwindowactivity extends Popupwindow {Activity context; Public testpopupwindowactivity (Activity context, View v) {super (context); This.context = context; Relativelayout Mcontentview = new Relativelayout (context); Relativelayout.layoutparams LPBG = new Relativelayout.layoutparams (ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); Mcontentview.setlayoutparams (LPBG); ImageView IVBG = new ImageView (context); Ivbg.setimageresource (R.mipmap.icon_alipay); Mcontentview.addview (IVBG); Mcontentview.measure (View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); This.setcontentview (Mcontentview); This.setheight (ViewGroup.LayoutParams.WRAP_CONTENT); This.setwidth (ViewGroup.LayoutParams.WRAP_CONTENT); This.setfocusable (TRUE); This.setbackgrounddrawable (New colordrawable (Color.gray)); This.setoutsidetouchable (TRUE); This.update (); int popupwidth = Mcontentview.getmeasuredwidth (); int popupheight = Mcontentview.getmeasuredheight (); int[] location = new INT[2]; V.getlocationonscreen (location); Showatlocation (V, gravity.no_gravity, location[0] + v.getwidth ()/2-POPUPWIDTH/2, location[1]-popupHeight); }}
Android Popup Window is highlighted above the control