title: How to get RelativeLayout to change height accordingly upon adding more Layouts to it's parent?
body: <p>Could some help me with Layouts? I'm having a problem getting it to display the way I'd like.</p>
  
  <p>I have two relativelayouts in a linearlayout. RelativeLayout 1 is used to accomodate a fragment, RelativeLayout 2 contains the 'main' layout that should fill the screen when there is no fragment, but resize when the fragment is added.</p>
  
  <p>I create the layouts dynamically like so:</p>
  
  <pre><code>    LinearLayout mainLayout = new LinearLayout(this);
      mainLayout.setLayoutDirection(LinearLayout.VERTICAL);
  
      unityPlayerLayout = new RelativeLayout(this);
      youtubeLayout = new RelativeLayout(this);
  
  
      LinearLayout.LayoutParams mainParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
  
      mainLayout.setLayoutParams(mainParams);
  
  
      RelativeLayout.LayoutParams youtubeLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,600);
  
      RelativeLayout.LayoutParams unityPlayerLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.MATCH_PARENT);
      unityPlayerLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
  
  
      mainLayout.addView(youtubeLayout,0,youtubeLayoutParams);
      mainLayout.addView(unityPlayerLayout);
      unityPlayerLayout.addView(playerView,0,unityPlayerLayoutParams);
  </code></pre>
  
  <p>Upon adding the fragment, unityPlayerLayout does not resize and aligned to the bottom though. It get's pushed to the right, I can see  a sliver of a couple of pixels, which is weird, since youtubeLayout and mainLayout should match the screen.</p>
  
  <p>So, to summarize: Upon adding a fragment to youtubeLayout, I need unityPlayerLayout to resize it's height and drop to the bottom, but in practice unityPlayerLayout gets pushed to the right, and does not resize it's height.</p>
  
  <p>Anyone any idea? Much appreciated!</p>