问题
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