title: Android RecyclerView smooth scroll to view that's animating their height
body: <p>I have a RecyclerView with Expandable Child Views, when the child ViewGroup is clicked it inflates an amount of views animating the ViewGroup height from 0 to the measured viewgroup height, like the following gif:</p>
  
  <p><img src="https://i.stack.imgur.com/HQH93.gif" alt="example"></p>
  
  <p>The problem is: I'm calling smoothScrollToPosition on recyclerView, it smooth scroll to the view position, but it considers the current view height, which is still not expanded, in the above gif i'm touching on the under view of the recyclerview, which dont scroll to position because the view is already visible, but when i touch again (calling the smoothscrolltoposition again) it scroll the view to the correct position, because the view is already expanded.</p>
  
  <p>Is there any approach to scroll the view to the top of screen or just scroll to make content visible?</p>
  
  <p>For references:
  This is the method called to inflate the views:</p>
  
  <pre><code>collapsible_content.removeAllViews();
  for(int i = 0; i &lt; 5; i++) {
          View link_view = getLayoutInflater().inflate(R.layout.list_item_timeline_step_link, collapsible_content, false);
          TextView text = (TextView) link_view.findViewById(R.id.step_link_text);
          text.setText("Test");
          collapsible_content.addView(link_view);
      }
  </code></pre>
  
  <p>And this is my method to expand:</p>
  
  <pre><code>public void toggle() {
          collapsible_content.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
          Animation a;
          if (mExpanded) {
              a = new ExpandAnimation(collapsible_content.getLayoutParams().height, 0);
          } else {
              a = new ExpandAnimation(collapsible_content.getLayoutParams().height, getMeasuredHeight());
          }
          a.setDuration(mAnimationDuration);
          collapsible_content.startAnimation(a);
          mExpanded = !mExpanded;
      }
  </code></pre>
  
  <p>And the animation:</p>
  
  <pre><code>private class ExpandAnimation extends Animation {
          private final int mStartHeight;
          private final int mDeltaHeight;
  
          public ExpandAnimation(int startHeight, int endHeight) {
              mStartHeight = startHeight;
              mDeltaHeight = endHeight - startHeight;
          }
  
          @Override
          protected void applyTransformation(float interpolatedTime,
                                             Transformation t) {
              final int newHeight = (int) (mStartHeight + mDeltaHeight *
                      interpolatedTime);
              collapsible_content getLayoutParams().height = newHeight;
  
              if (newHeight &lt;= 0) {
                  collapsible_content setVisibility(View.GONE);
              } else {
                  collapsible_content setVisibility(View.VISIBLE);
              }
              collapsible_content requestLayout();
          }
  
  
          @Override
          public boolean willChangeBounds() {
              return true;
          }
      }
  </code></pre>