外界接触后,避免PopupWindow解雇 [英] Avoiding PopupWindow dismissal after touching outside

查看:139
本文介绍了外界接触后,避免PopupWindow解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个PopupWindow有下列行为/特点:

I would like to use a PopupWindow with following behaviours/features:

  • 这是可聚焦(具有交互式控制内如:按钮)
  • 在popupwindow下视图已经消耗弹出的正确
  • 之外的接触
  • ..但popupwindow已经留在屏幕上点击,甚至后外

我发现一堆关于PopupWindow职位,但没有人问的一个问题是如何处理这种情况。

I've found bunch of posts regarding PopupWindow but none of them asked question how to deal with such situation..

我想我试过setOutsideTouchable(每一个可能的组合),setFocusable(),setTouchable(),但我坚持。弹出处理得当就可以点击,但它触及外面当的驳回始终。

I think I tried every possible combination of setOutsideTouchable(), setFocusable(),setTouchable() but I'm stuck. Popup deals with clicks on it properly, but it's dismissed always when touching outside.

我目前的code是:

My current code is :

View.OnTouchListener customPopUpTouchListenr = new View.OnTouchListener(){

    @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
        Log.d("POPUP", "Touch false");
        return false;
    }

};


LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout layout= (LinearLayout)inflater.inflate(R.layout.insert_point_dialog, null);
PopupWindow pw = new PopupWindow(layout,400,200,true);
pw.setOutsideTouchable(true);
pw.setTouchable(true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.setTouchInterceptor(customPopUpTouchListenr);
pw.showAtLocation(frameLayout, Gravity.BOTTOM, 0, 0);

我的总体目标是建立一个浮动窗口,它表现像软件一样瘸子一个工具选项板:直到关闭了X按钮,并允许外,在与对照进行交互内部有一些控制,停留在顶端它.. 也许有一些更好的方法来做到这一点,而不是一个PopupWindow?但我还没有找到更合适的控制。

My general goal is to create a floating window which behaves like a 'tools palette' in software like gimp: has some controls inside, stays on top until closed by 'X' button, and allowing to interact with controls outside-under it.. Maybe there's some better way to do this, not a PopupWindow? But I still haven't found more suitable control.

推荐答案

只是删除​​ pw.setBackgroundDrawable(新BitmapDrawable());

这篇关于外界接触后,避免PopupWindow解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆