title: How can I draw ItemDecoration correctly when RecyclerView element is animating its height?
body: <p>I have a RecyclerView that uses a LinearLayoutManager (vertical). What I am trying to accomplish is having the item decoration (full width and 1px tall) divider animate with the view when the view is moved (the translationY() deals with that properly) and when the view changes its height. In the current code that I have below, the divider will jump to the future position of the bottom of the view rather than the current bottom during the animation. Is there any way I can account for the height changes in the item decoration during the animation to make the animation look better?</p>
  
  <p>I am changing the view height by using notifyItemChanged() on the adapter for the RecyclerView.</p>
  
  <pre><code>public class DividerItemDecoration extends RecyclerView.ItemDecoration {
      private Drawable mDivider;
  
      public DividerItemDecoration(Context context) {
          mDivider = context.getResources().getDrawable(R.drawable.line_divider);
      }
  
      @Override
      public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
          int right = parent.getWidth();
          int dividerHeight = mDivider.getIntrinsicHeight();
  
          int childCount = parent.getChildCount();
          for (int i = 0; i &lt; childCount - 1; i++) {
              View child = parent.getChildAt(i);
              View nextChild = parent.getChildAt(i + 1);
  
              RecyclerView.LayoutParams layoutParams1 =
                      (RecyclerView.LayoutParams) child.getLayoutParams();
              RecyclerView.LayoutParams layoutParams2 =
                      (RecyclerView.LayoutParams) nextChild.getLayoutParams();
              int left = 0;
              if (layoutParams1 != null &amp;&amp; layoutParams2 != null) {
                  left = Math.min(layoutParams1.leftMargin, layoutParams2.leftMargin);
              }
  
              int ty = (int) (child.getTranslationY() + 0.5f);
              int top = child.getBottom() + ty;
              int bottom = top + dividerHeight;
  
              mDivider.setBounds(
                      left,
                      top,
                      right,
                      bottom);
              mDivider.draw(c);
          }
      }
  }
  </code></pre>