“TYPE_ACCESSIBILITY_OVERLAY"类型的叠加隐藏导航按钮 [英] Overlay of type "TYPE_ACCESSIBILITY_OVERLAY" hides navigation buttons

查看:73
本文介绍了“TYPE_ACCESSIBILITY_OVERLAY"类型的叠加隐藏导航按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这些布局参数向窗口管理器添加一个视图:

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
);

预期的结果是一个覆盖整个屏幕的覆盖窗口,除了系统 ui(导航栏和状态栏),没有覆盖软键盘.

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.

当前结果:

预期结果:

我尝试了几个标志,例如:

I've tried a couple of flags like:

WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR

和以下组合:

WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN

但他们都没有工作.我还浏览了系统用户界面文档,但大多数选项都涉及WindowManager.LayoutParams 标志用于隐藏装饰,其余标志需要对窗口的引用,我认为我无法从无障碍服务中获得.

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.

问题似乎是:

WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM

flag,如果我删除它,导航按钮是可见的,但覆盖层会覆盖键盘,即使我使用这样的东西它也会这样做:

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;

我的问题:

有没有办法让覆盖层不覆盖键盘并且不隐藏导航栏按钮?

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

推荐答案

您是否尝试从 PixelFormat.TRANSLUCENT 切换到 PixelFormat.TRANSPARENT?还有:

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
    }

这篇关于“TYPE_ACCESSIBILITY_OVERLAY"类型的叠加隐藏导航按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆