private void drawDividersHorizontal(Canvas canvas) { final int count = getChildCount(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child != null && child.getVisibility() != GONE) { if (hasDividerBeforeChildAt(i)) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int left = child.getLeft() - lp.leftMargin /* - mDividerWidth*/; drawVerticalDivider(canvas, left); } } } if (hasDividerBeforeChildAt(count)) { final View child = getChildAt(count - 1); int right; if (child == null) { right = getWidth() - getPaddingRight() - mDividerWidth; } else { // final LayoutParams lp = (LayoutParams) child.getLayoutParams(); right = child.getRight() /* + lp.rightMargin*/; } drawVerticalDivider(canvas, right); } }