[color=blue][size=large]View contentView = LayoutInflater.from(mContext).inflate(R.layout.popup_win, null, false);
popupWindow = new PopupWindow(findViewById(R.id.layout),
(int)(winWidth * 1.0), (int)(winHeight * 1.0), true);
popupWindow.setContentView(contentView);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.showAtLocation(((TableLayout)findViewById(R.id.layout)), Gravity.CENTER, 0, 0);
如果希望触发Back键或者点击在popupWindow以外的区域让其dismiss,只需加上以上两行即可:
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());[/size][/color]
popupWindow = new PopupWindow(findViewById(R.id.layout),
(int)(winWidth * 1.0), (int)(winHeight * 1.0), true);
popupWindow.setContentView(contentView);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.showAtLocation(((TableLayout)findViewById(R.id.layout)), Gravity.CENTER, 0, 0);
如果希望触发Back键或者点击在popupWindow以外的区域让其dismiss,只需加上以上两行即可:
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());[/size][/color]