从任何应用程序按下后退按钮时清除android覆盖

时间:2017-05-31 22:34:17

标签: android android-layout

关于此问题最接近的问题是这个问题here,但它没有回答我的问题。

我正在开发一个字典应用程序,允许用户从任何应用程序访问字词定义。这项工作到目前为止如下图所示。

Overlay when in app or any other app

然而,当我点击主页时,叠加仍然显示但我不想要这个。我希望叠加在其显示的屏幕更改时被删除。 Overlay when not in any app. This is wrong

我曾尝试在窗口管理器中使用TYPE_APPLICATION,但它根本不起作用。它说有些东西不能添加令牌null。

请查看我的windowManager代码:

DISPLAY_ID = (windowManager as WindowManager).defaultDisplay.displayId
        params = WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_PHONE,
                WindowManager.LayoutParams.FLAG_FULLSCREEN,
                PixelFormat.TRANSLUCENT)

        (params as WindowManager.LayoutParams).gravity = Gravity.BOTTOM

然后我把它全部解决了

windowManager?.addView(dictionaryView, params)

0 个答案:

没有答案