在后台服务中隐藏导航栏 - android

时间:2015-12-28 06:49:21

标签: android-studio navigationbar

我有一个应用程序,它为所有其他正在运行的应用程序(基本上是作为后台服务运行的过滤器)引入半透明视图。我面临的问题是该应用程序不会在导航栏上应用过滤器(带有后面,主页和最近标签按钮的底栏)。

我用于创建视图的标志显示在下面的代码中:

 WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                0 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                PixelFormat.TRANSLUCENT);
        WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
        wm.addView(mView, params);

是否有任何特殊标志或其他任何我需要覆盖导航栏的内容?

This is the screenshot of the filter running with everything else covered except the nav bar

1 个答案:

答案 0 :(得分:0)

在layoutparams中添加Y偏移,使叠加层覆盖导航栏。

 WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT,0, navbarHeight(),
                WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                0 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                PixelFormat.TRANSLUCENT);
        WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
        wm.addView(mView, params);

private int navbarHeight() {
...code to calculate height of navbar
}