androidopengl-essurfaceviewglsurfaceview

How to offset GLSurfaceView to account for status bar?


Currently when I draw at 0,0 the status bar covers the drawing. Is there a way to adjust the position of the surface or do I need to build a draw offset in to account for status bar - effectively drawing everything starting at y=25?


Solution

  • I'm not sure why the surfaceview overlaps the status bar (sounds like an android bug), but the easiest thing would probably be to use glViewport to just define which area of the surfaceview you intend to use for drawing.

    If you can figure out how high the status bar is, then just subtract that from the height of your glViewport call, and then all your calls will be mapped to just inside the viewport range.