title: changing the height of a parent layout changes the height of a view inside it
body: <p>I have 2 LinearLayouts inside a FrameLayout as an Item for a recyclerView.</p>
  
  <p>I want the FrameLayout to have the size of the LinearLayout that is above and when I click the FrameLayout I set the translationY of the LinearLayout that is below so you can't see it and then I animate it in.
  to achieve this I set the height of the FrameLayout to the height of the layout that is above like this:</p>
  
  <pre><code>        holder.llAbove.post(new Runnable() {
          @Override
          public void run() {
              holder.flContent.getLayoutParams().height = holder.llAbove.getHeight();
              holder.flContent.requestLayout();
          }
      });
  </code></pre>
  
  <p>and when I press it  I set the translationY of the layout that is below and animate it in.
  this works great when the size of the layout that is below is fixed, but when I set it's height to wrap_content the height of the below layout becomes the size of the main FrameLayout, which screws everything up.</p>
  
  <p>I tried changing the entire layout params instead of just the height like this:</p>
  
  <pre><code>        holder.llAbove.post(new Runnable() {
          @Override
          public void run() {
              FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT,holder.llAbove.getHeight());
              holder.flContent.setLayoutParams(layoutParams);
          }
      });
  </code></pre>
  
  <p>but then I get this Exception:</p>
  
  <pre><code>03-29 15:36:22.919    4298-4298/com.example.itayrabin.layouttest E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.example.itayrabin.layouttest, PID: 4298
  java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.support.v7.widget.RecyclerView$LayoutParams
  </code></pre>
  
  <p>and when I changed the layout params to RecylcerView.LayoutParms like this:</p>
  
  <pre><code>        holder.llAbove.post(new Runnable() {
          @Override
          public void run() {
              RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT,holder.llAbove.getHeight());
              holder.flContent.setLayoutParams(layoutParams);
          }
      });
  </code></pre>
  
  <p>I get this null reference exception:</p>
  
  <pre><code>03-29 15:38:10.554    4359-4359/com.example.itayrabin.layouttest E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.example.itayrabin.layouttest, PID: 4359
  java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.v7.widget.RecyclerView$ViewHolder.shouldIgnore()' on a null object reference
  </code></pre>
  
  <p>I have tried anything I can think of.</p>
  
  <p>can anyone help me?</p>