1PopupWindow popup = new PopupWindow(contentView, width, height);
2popup.setBackgroundDrawable(background);
3popup.showAsDropDown(anchor);
4
5View container = (View) popup.getContentView().getParent();
6WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
7WindowManager.LayoutParams p = (WindowManager.LayoutParams) container.getLayoutParams();
8// add flag
9p.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
10p.dimAmount = 0.3f;
11wm.updateViewLayout(container, p);
12