title: How to move a shape created in onDraw method to center on screen?
body: <p>I am trying to move a rectangle that i created to the center of the screen as I am using an accelerometer to allow it to move, is there a way to move the shape to the center of the screen without using android xml?</p>
  
  <pre><code>public class CustomDrawableView extends View
      {
          static final int width = 150;
          static final int height = 250;
  
          public CustomDrawableView(Context context)
          {
              super(context);
  
              mDrawable = new ShapeDrawable(new RectShape());
              mDrawable.getPaint().setColor(0xff74AC23);
              mDrawable.setBounds(x, y,  x + width, y + height);
  
          }
  
          protected void onDraw(Canvas canvas)
          {
  
              RectF rect = new RectF(AccelActivity.x, AccelActivity.y, AccelActivity.x + width, AccelActivity.y
                      + height); // set bounds of rectangle
              Paint p = new Paint(); // set some paint options
              p.setColor(Color.BLUE);
              canvas.drawRect(rect, p);
              invalidate(); 
  
          }
      }
  }
  </code></pre>