title: Animate newly created View of unknown size
body: <p>I want to animate View right after it was added to parent (something like DrawerLayout). The problem is that View has varying size, and animation target position depends on that size. Simplified sample code:</p>
  
  <pre><code>    AnimatingView extends View {
          public int offsetX;
  
          @Override
          protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
              final int screenWidth = MeasureSpec.getSize(widthMeasureSpec);
              final int screenHeight = MeasureSpec.getSize(heightMeasureSpec);
              offsetX = calculateOffset(screenWidth);
              ...
          }
      }
  </code></pre>
  
  <p>Code similar to this triggers the animation:</p>
  
  <pre><code>    @Override
      public void onClick(View v) {
          AnimatingView animatingView = new AnimatingView(getContext());
          parentLayout.addView(animatingView);
          animatingView.animate().x(animatingView.offsetX).setDuration(500).start();
      }
  </code></pre>
  
  <p>In this case <code>onMeasure()</code> happens after <code>animate()</code>, so animation fails. What is the correct way of doing stuff which depends on view measuring?</p>
  
  <p>The simple &amp; stupid way would be something like <code>animateOnceAfterMeasuring()</code> based on <code>isInitialized</code> flag, but I don't think it the correct way of doing this.</p>