欢迎使用CSDN-markdown编辑器

android dialog 升起时,保持后台输入法仍然打开

这里有两个重要的参数,现拷贝如下:
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IMWindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
这两个参数相互作用能够应对dialog升起时,后台输入法的状态。

现有两个dialog,第一个dialog先弹出,上面有个EditText,第二个dialog后弹出,上面不可以输入内容,如何保持第二个dialog弹出时,第一个dialog上的输入法不消失呢?就是上面用到的两个参数。(如何判断一个dialog上有没有可编辑的输入框,AlertDialog会遍历View,并使用View的onCheckIsTextEditor()方法来检查有没有可编辑内容)

  1. FLAG_ALT_FOCUSABLE_IM没有设置,FLAG_NOT_FOCUSABLE没有设置
    不做讨论

  2. FLAG_ALT_FOCUSABLE_IM设置,FLAG_NOT_FOCUSABLE没有设置
    键盘会在底部,弹框能够覆盖在输入法上面,且能接受反馈键指令,按返回键第二个弹框消失。

  3. FLAG_ALT_FOCUSABLE_IM没有设置,FLAG_NOT_FOCUSABLE设置
    键盘会在底部,弹框能够覆盖在输入法上面,但是不能接受Button指令,按返回键,底部的键盘消失和第一个dialog消失,第二个dialog还在。

  4. FLAG_ALT_FOCUSABLE_IM设置,FLAG_NOT_FOCUSABLE设置
    键盘会在第二个dialog上面,弹框不能够覆盖在输入法上面,也不能接受Button指令,按返回键,底部的键盘消失,第一个dialog消失,第二个dialog还在。


   /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
         * respect to how this window interacts with the current method.  That
         * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
         * window will behave as if it needs to interact with the input method
         * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
         * not set and this flag is set, then the window will behave as if it
         * doesn't need to interact with the input method and can be placed
         * to use more space and cover the input method.
         */
        public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
    /** Window flag: this window won't ever get key input focus, so the
         * user can not send key or other button events to it.  Those will
         * instead go to whatever focusable window is behind it.  This flag
         * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
         * is explicitly set.
         *
         * <p>Setting this flag also implies that the window will not need to
         * interact with
         * a soft input method, so it will be Z-ordered and positioned
         * independently of any active input method (typically this means it
         * gets Z-ordered on top of the input method, so it can use the full
         * screen for its content and cover the input method if needed.  You
         * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
        public static final int FLAG_NOT_FOCUSABLE      = 0x00000008;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值