1
我需要制作一个带有几个按钮的弹出式窗口。按钮需要点击,所以我将popupWindow属性设置为可调焦。但只要我在popupWindow之外触摸,弹出窗口就会被解除。弹出窗口与EditText关联。我的要求是,即使弹出窗口可见,用户也必须能够输入editText。可调焦弹出式窗口,带有可调焦背景
pWindow = new PopupWindow(context);
pWindow.setBackgroundDrawable(new BitmapDrawable());
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
popupView = (RelativeLayout) inflater.inflate(R.layout.popup, null);
popupView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
pWindow.setContentView(popupView);
pWindow.setWidth(popupView.getLayoutParams().width);
pWindow.setHeight(popupView.getLayoutParams().height);
pWindow.setFocusable(true);
pWindow.setTouchable(true);
pWindow.showAsDropDown(anchor, 0, 0);
我试过各种组合,但无法达到预期的效果。
谢谢。我会试试这个。同时,我已经通过在需要弹出窗口的位置创建viewstub并更改其可见性来实现它。 – rDroid