title: Android - correct for height of status bar in onTouchEvent()
body: <p>I respond to touch events inside a custom View in <code>onTouchEvent(MotionEvent event)</code>.   I'm having trouble with an inconsistency in coordinates: <code>event.getRaw(Y)</code> returns the Y coordinate of a touch including the status bar, but <code>myView.getTop()</code> returns the Y coordinate of the top of the view excluding the status bar.  I've resorted to the following hack to correct for the height of the status bar:</p>
  
  <pre><code>// Get the size of the visible window (which excludes the status bar)
  Rect rect = new Rect();
  getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
  
  // Get the coordinates of the touch event, subtracting the top margin
  final int x = (int) event.getRawX();
  final int y = (int) event.getRawY() - rect.top;
  </code></pre>
  
  <p>Is there a better solution?</p>