title: Layout params getWidth() returns zero
body: <p>i have a <code>RelativeLayout</code> here's the code :</p>
  
  <pre><code>&lt;RelativeLayout
     android:id="@+id/camerapreview"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_margin="10dp"
     android:background="#000"&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>its a camera preview for the camera application, i set the <code>width</code> to <code>match_parent</code>.</p>
  
  <p>and here is my java code : </p>
  
  <pre><code>RelativeLayout preview = (RelativeLayout) findViewById(R.id.camerapreview);
  int w = preview.getWidth();
  LayoutParams params = preview.getLayoutParams();
  params.width = w;
  params.height = w;
  preview.addView(mPreview);
  </code></pre>
  
  <p>basically i decalaired the width of the <code>RelativeLayout</code> to <code>match_parent</code> to be dynamic to the width of any device. But i want the view to be square so i used the <code>java code</code> abave, but every time i ran the program this line <code>int w = preview.getWidth();</code> returns zero. I must have missed something, help please :D thank you.</p>