我有两个布局,一个布局80%的屏幕和其他20%的屏幕(lanscape模式),在20%的屏幕布局上我有几个垂直按钮。点击每个按钮弹出窗口将出现80%的屏幕布局,在弹出窗口外触摸,弹出窗口将被解雇。我的问题是触摸80%的屏幕,弹出窗口应该不在20%的屏幕上解除。
Ref_channel.setOnClickListener(new OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
width_device = size.x;
X = (width_device - Ref_channel.getWidth());
layoutInflater = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
popupView = layoutInflater.inflate(R.layout.refchannel_popup,
null);
popupView.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int s = X - (int) ((popupView.getMeasuredWidth()));
pup1 = new PopupWindow(popupView,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
pup1.setBackgroundDrawable(new BitmapDrawable());
pup1.setFocusable(true);
pup1.showAtLocation(Ref_channel, 0, s, 0);
}
});
答案 0 :(得分:0)
您使用过:pup1.setOutsideTouchable(true);
将此属性设置为“false”。
答案 1 :(得分:0)
替换此
pup1.setOutsideTouchable(true);
用这个:
pup1.setOutsideTouchable(false);
答案 2 :(得分:0)
我得到了解决方案。在80%的布局中,创建layout.setontouchlistener并在action_down中我忽略了弹出窗口。 ref_pup.dismiss();