title: Set layout params dynamically
body: <p>I'm using the CameraPreview example API demo. I need to add some views (button, etc..) overlaying the SurfaceView.</p>
  
  <p>For this, I'm trying to set their parameters, but they appear all the time on the top-left side of the screen.</p>
  
  <p>This is the onCreate method of the code:</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  
          btnTakePhoto = new Button(this);
          btnTakePhoto.setBackgroundResource(android.R.drawable.ic_menu_camera);
  
  
          /*Set container*/
          mPreview = new Preview(this);
          setContentView(mPreview);
  
          /*Set button params and add it to the view*/
          RelativeLayout.LayoutParams buttonParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
          buttonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
          buttonParams.addRule(RelativeLayout.CENTER_VERTICAL);
          addContentView(btnTakePhoto, buttonParams);
  
  
          numberOfCameras = Camera.getNumberOfCameras();
  
          CameraInfo cameraInfo = new CameraInfo();
          for (int i = 0; i &lt; numberOfCameras; i++) {
              Camera.getCameraInfo(i, cameraInfo);
              if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
                  defaultCameraId = i;
              }
          }
      }
  </code></pre>
  
  <p>Have to say that the values here </p>
  
  <pre><code>RelativeLayout.LayoutParams buttonParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  </code></pre>
  
  <p>are updating well if I change them. What doesn't change is what contains the addRule() method</p>