简体   繁体   English

“TYPE_ACCESSIBILITY_OVERLAY”类型的叠加层隐藏了导航按钮

[英]Overlay of type “TYPE_ACCESSIBILITY_OVERLAY” hides navigation buttons

I'm adding a view to windows manager using these layout parameters:我正在使用以下布局参数向 windows 管理器添加视图:

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.预期的结果是覆盖 window 覆盖除系统 ui(导航栏和状态栏)之外的整个屏幕并且不覆盖软键盘。

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.我还浏览了系统 ui 的文档,但是其中涉及WindowManager.LayoutParams标志的大多数选项用于隐藏装饰,并且其中的 rest 需要对 window 的引用,我认为我无法从辅助功能服务中获得.

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?您是否尝试从 PixelFormat.TRANSLUCENT 切换到 PixelFormat.TRANSPARENT? Also:还:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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