如何在键盘下绘制其他应用程序?

时间:2016-07-22 08:10:59

标签: android android-windowmanager

我正在开发一款在屏幕上绘制气泡的浮动应用。我想让键盘出现时总是在键盘下面,或者至少要抓住键盘事件。

以下是我用来将气泡添加到窗口管理器的参数代码:

         params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_PHONE,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
                PixelFormat.TRANSLUCENT);

我已尝试过所有窗口类型/标志,但无法实现。我知道这是可能的,因为“EAS:简易应用程序切换器”做到了。

我真的希望有人能在这方面给我启发。提前感谢您的时间!

1 个答案:

答案 0 :(得分:0)

我只是遇到了同样的问题,终于找到了解决方案。尽管它可能不再对您有帮助,但希望它将对遇到相同问题的其他人有所帮助。

所需的标志是WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IMWindowManager.LayoutParams.FLAG_NOT_FOCUSABLE的组合。

这是javadoc关于该标志的内容:

    /** 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.
     */