Overlay of type “TYPE_ACCESSIBILITY_OVERLAY” hides navigation buttons

本秂侑毒 提交于 2021-02-10 14:24:01

问题


I'm adding a view to windows manager using these layout parameters:

WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
            WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
            WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT
);

The expected result is an overlay window that covers the entire screen except the system ui (navigation bar and status bar) and doesn't cover the soft keyboard.

The above parameters do that but the problem is that the navigation bar buttons are not visible while the soft keyboard is open.

Current result:

Expected result:

I've tried a couple of flags like:

WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR

and a combination of:

WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN

But none of them worked. I've also gone through the documentation for system ui but most option there that involve WindowManager.LayoutParams flags are for hiding the decoration and the rest of them require a reference to the window which I don't think I can get from an accessibility service.

The problem seems to be the:

WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM

flag, if I remove it, the navigation buttons are visible but the overlay will cover the keyboard, it will do that even if I use something like this:

params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;

My question:

Is there any way to have an overlay that doesn't cover the keyboard and doesn't hide the navigation bar buttons ?

来源:https://stackoverflow.com/questions/58819647/overlay-of-type-type-accessibility-overlay-hides-navigation-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!