title: Draw over navigation bar (and other apps) on Android version >= 5
body: <p>I'd like to draw a (mouse pointer) icon on screen over the other applications from a service. I have implemented the functionality and I can draw over the screen, apart from the navigation bar. I've researched <a href="https://stackoverflow.com/questions/21382283/android-navigation-bar-overlay">several</a> <a href="https://stackoverflow.com/questions/21380167/draw-bitmaps-on-top-of-the-navigation-bar-in-android">other</a> <a href="https://stackoverflow.com/questions/4481226/creating-a-system-overlay-window-always-on-top">questions</a> here and tried <code>TYPE_SYSTEM_OVERLAY</code>, <code>TYPE_TOAST</code>, <code>TYPE_SYSTEM_ERROR</code> and some other window types without success.</p>
  
  <p>I'm not trying to capture focus, just drawing a mouse pointer on the screen for a second or two. When I try to draw over navigation bar, it just goes under (actually, the RelativeLayout ends on the border with navigation bar - even when I specify manual dimension for height). The screenshot below shows the hand pointer in the lower right part of the screen. That's as low as I can position it. Note that I'm not trying to hide the navigation bar in my application - trying to draw over other apps.</p>
  
  <p><img src="https://i.stack.imgur.com/SOcQx.png" alt="overlay-pointer-on-screen"></p>
  
  <p>I even tried setting the <code>xpos</code> and <code>ypos</code> offset settings in <code>WindowManager.LayoutParams</code> instance, but that just offsets the layout and still goes below the navigation bar).</p>
  
  <p>The layout params I'm using to show this window:</p>
  
  <pre><code>        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                  WindowManager.LayoutParams.MATCH_PARENT,
                  WindowManager.LayoutParams.MATCH_PARENT,
                  WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                  WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
                  WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                  WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                  PixelFormat.TRANSPARENT);
  </code></pre>
  
  <p>I am then adding the <code>RelativeLayout</code> with those parameters to the WindowManager: <code>windowManager.addView(relativeLayout, params);</code></p>