How to disable RecyclerView item decoration drawing for the duration of item animations

It may depend somewhat on the type of animation you're using, but at least for DefaultItemAnimator you need to account for the X/Y translation being done during the animation. You can get these values with child.getTranslationX() and child.getTranslationY().

For example, for the vertical case of onDraw/onDrawOver:

private void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();
    final int childCount = parent.getChildCount();
    final int dividerHeight = mDivider.getIntrinsicHeight();

    for (int i = 1; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int ty = (int)(child.getTranslationY() + 0.5f);
        final int top = child.getTop() - params.topMargin + ty;
        final int bottom = top + dividerHeight;
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}

(You may prefer to use ViewCompat.getTranslationY(child) if you need to support < API 11.)

Note: for other types of animations, additional adjustments may need to be made. (For example, horizontal translation might also need to be accounted for.)


Found an answer myself:

To hide item decorations during an item animation one can simply use this check in onDraw/onDrawOver:

public void onDrawOver(..., RecyclerView parent, ...) {
    if(parent.getItemAnimator() != null && parent.getItemAnimator().isRunning()) {
        return;
    }
    // else do drawing stuff here
}