Draw bitmaps on top of the Navigation bar in Android

一世执手 提交于 2020-01-11 03:33:06

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/21380167/draw-bitmaps-on-top-of-the-navigation-bar-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!