绘制位图在Android的导航栏的顶部位图、Android

2023-09-06 22:58:08 作者:白日依山尽

在我的应用程序,我需要借助位图上的所有应用程序运行的顶部。我创建了一个视图,它是无形的,覆盖所有的应用程序的顶部。与此叠加观点我可以在给定的位置绘制位图,但我不能画上的导航Bar.I顶部的位图中使用以下布局的参数。

In my application, I need to draw a bitmap on top of all the apps running. I created a view which is invisible and overlays on top of all the apps. with this overlay view I can draw bitmaps at the given position , But I am unable to draw the bitmap on top of the Navigation Bar.I used the following layout parameters.

    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
    WindowManager.LayoutParams.FLAG_FULLSCREEN
    |WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
    |WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
    |WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR 
    |WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,

我需要在解决这一问题有所帮助。在此先感谢

I need help in solving this issue. Thanks in advance

推荐答案

我已经解决了这个问题我自己,在机器人的底部借鉴导航栏上面,我必须给一个在Y位置偏移而确定在windowManager.Layout PARAMS如下图所示。

I have solved the issue myself , to draw on top of navigation bar at the bottom of the android , I have to give an offset in the Y position while defining the windowManager.Layout params as below.

w = new android.view.WindowManager.LayoutParams(-1, -1,0,-navigationBarHeight(),    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
    WindowManager.LayoutParams.FLAG_FULLSCREEN
    |WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
    |WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
    |WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR 
    |WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, Pixel.Translucent);
    f.addView(v, w);

请注意:这只有在导航栏是半透明

note: This only works when the navigation bar is translucent