I know that I have to leave a comment, but the code in the comment is hard to read, so I summed up another answer. Opiatefuchs answer is actually correct. but there is one thing you should notice if you want to check its code.
float centerWidth = canvas.getWidth()/2; //get center x of display float centerHeight = canvas.getHeight()/2; //get center y of display
centerWidth and centerHeight should be obtained as shown below, or nothing will be drawn on your screen. and circleDistance = 200 is a little big for a regular phone screen (as for my samsung i9300, 200 is too large, the second circle is outside the range of the screen, for example, you change it to a lower value of 80.)
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); centerWidth = w / 2; centerHeight = h / 2; }
screenshot.

source share