@Override public void draw(@NonNull Canvas canvas) { super.draw(canvas); if (leftGlow != null) { final int scrollX = getScrollX(); if (!leftGlow.isFinished()) { final int restoreCount = canvas.save(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); canvas.rotate(270); canvas.translate(-height + getPaddingTop(), Math.min(0, scrollX)); leftGlow.setSize(height, getWidth()); if (leftGlow.draw(canvas)) { postInvalidate(); } canvas.restoreToCount(restoreCount); } if (!rightGlow.isFinished()) { final int restoreCount = canvas.save(); final int width = getWidth(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); canvas.rotate(90); canvas.translate(-getPaddingTop(), -(Math.max(getScrollRange(), scrollX) + width)); rightGlow.setSize(height, width); if (rightGlow.draw(canvas)) { postInvalidate(); } canvas.restoreToCount(restoreCount); } } }