title: Android: Rotate whole layout
body: <p>I need to be able to rotate whole layouts on the fly (on the click of a button).</p>
  
  <p>I am able to rotate the layouts using, eg. <code>layout.setRotation(270.0f)</code>. <strong>The problem is, after the rotation, the layout <code>height</code> and <code>width</code> are not matching its parent's</strong>.</p>
  
  <p>I have tried inverting <code>height</code> and <code>width</code> like so, </p>
  
  <pre><code>RelativeLayout layout = (RelativeLayout)findViewById(R.id.rootLayout);
  LayoutParams layoutParams = layout.getLayoutParams();
  int height = layout.getHeight();
  int width = layout.getWidth();
  layoutParams.height = width;
  layoutParams.width = height;
  </code></pre>
  
  <p>Which does nothing at all.</p>
  
  <p>I am working with <code>sdk 14</code>.</p>
  
  <p>The first image below is the app as it starts. The second one, after a rotation. I wish to fill the black "space". Any help would be appreciated.</p>
  
  <p>The images below show only a button in the layout. However, in reality, the layout are a lot more complex. What I am trying to achieve is "faking" a landscape view.</p>
  
  <p><img src="https://i.stack.imgur.com/z3x4r.png" alt="When starting">
  <img src="https://i.stack.imgur.com/iU5D2.png" alt="After rotation"></p>
  
  <p><strong>Edit:</strong> Changed images and added descriptions.</p>