Your issue is that by default, XML uses a thing called Titlebar, as answered here. Along with removing the Titlebar, you can set your activity to full-screen and also remove the status-bar by using this solution.
Make sure that your activity imports from Activity
rather than ActionBarActivity
.
Also, it is better to avoid using actual numbers when setting a position or a size, and especially when the goal is to cover the entire screen. You can get the width and height of the screen by using getWidth()
and getHeight()
accordingly:
canvas.drawRect(0, 0, getWidth(), getHeight());
Make sure to use these methods only in or after the onDraw
method was called, else their values will be equal to 0 since the canvas was not yet initialized.