简体   繁体   中英

Overlay of type “TYPE_ACCESSIBILITY_OVERLAY” hides navigation buttons

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?

Did you try switching from PixelFormat.TRANSLUCENT to PixelFormat.TRANSPARENT? Also:

.apply {
        gravity = Gravity.BOTTOM //CENTER or whatever
        x = 0
        y = 0
        screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM