title: Draw multiple rectangles android canvas
body: <p>I'm trying to draw 4 rectangles on the canvas so that the canvas is divided in 4 equal rectangles. With the code I now have, only the last rectangle in my code is drawn. </p>
  
  <p>This is the code in my Activity:</p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
       ...
  setContentView(new MyView(this));
   }
  
  public class MyView extends View {
  
      public MyView(Context context) {
          super(context);
          // TODO Auto-generated constructor stub
          setFocusableInTouchMode(true);
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
  
          super.onDraw(canvas);
          int x = getWidth();
          int y = getHeight();
  
  
          Paint paintTopLeft = new Paint();
          paintTopLeft.setStyle(Paint.Style.FILL);
          paintTopLeft.setColor(Color.WHITE);
          canvas.drawPaint(paintTopLeft);
          // Use Color.parseColor to define HTML colors
          paintTopLeft.setColor(Color.parseColor("#F44336"));
          canvas.drawRect(0,0,x / 2,y / 2,paintTopLeft);
  
          Paint paintTopRight = new Paint();
          paintTopRight.setStyle(Paint.Style.FILL);
          paintTopRight.setColor(Color.WHITE);
          canvas.drawPaint(paintTopRight);
          // Use Color.parseColor to define HTML colors
          paintTopRight.setColor(Color.parseColor("#2196F3"));
          canvas.drawRect(x / 2, 0, x, y / 2, paintTopRight);
  
      }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>