@Override
  protected void measureChildWithMargins(
      View child,
      int parentWidthMeasureSpec,
      int widthUsed,
      int parentHeightMeasureSpec,
      int heightUsed) {
    final int index = indexOfChild(child);
    final int orientation = getOrientation();
    final LayoutParams params = (LayoutParams) child.getLayoutParams();
    if (hasDividerBeforeChildAt(index)) {
      if (orientation == VERTICAL) {
        // Account for the divider by pushing everything up
        params.topMargin = mDividerHeight;
      } else {
        // Account for the divider by pushing everything left
        params.leftMargin = mDividerWidth;
      }
    }

    final int count = getChildCount();
    if (index == count - 1) {
      if (hasDividerBeforeChildAt(count)) {
        if (orientation == VERTICAL) {
          params.bottomMargin = mDividerHeight;
        } else {
          params.rightMargin = mDividerWidth;
        }
      }
    }
    super.measureChildWithMargins(
        child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
  }
 @Override
 protected void onDraw(Canvas canvas) {
   if (mDivider != null) {
     if (getOrientation() == VERTICAL) {
       drawDividersVertical(canvas);
     } else {
       drawDividersHorizontal(canvas);
     }
   }
   super.onDraw(canvas);
 }